Skip to content

Commit a4084e0

Browse files
committed
add SD detection to INFO.txt
1 parent 26e0248 commit a4084e0

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

linker/nrf52.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ MEMORY
2828
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
2929

3030
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
31-
* from application to bootloader when using buttonluss DFU OTA. */
31+
* from application to bootloader when using buttonless DFU OTA. */
3232
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
3333

3434

linker/nrf52833.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ MEMORY
2929
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
3030

3131
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
32-
* from application to bootloader when using buttonluss DFU OTA. */
32+
* from application to bootloader when using buttonless DFU OTA. */
3333
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
3434

3535

linker/nrf52840.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ MEMORY
3131
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
3232

3333
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
34-
* from application to bootloader when using buttonluss DFU OTA. */
34+
* from application to bootloader when using buttonless DFU OTA. */
3535
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
3636

3737

src/usb/uf2/ghostfat.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "configkeys.h"
55
#include "flash_nrf5x.h"
66
#include <string.h>
7+
#include <stdio.h>
78

89
#include "bootloader_settings.h"
910
#include "bootloader.h"
@@ -67,13 +68,12 @@ struct TextFile {
6768
#define STR0(x) #x
6869
#define STR(x) STR0(x)
6970

70-
const char infoUf2File[] = //
71+
char infoUf2File[128*3] =
7172
"UF2 Bootloader " UF2_VERSION "\r\n"
7273
"Model: " UF2_PRODUCT_NAME "\r\n"
73-
"Board-ID: " UF2_BOARD_ID "\r\n"
74-
"Date: " __DATE__ "\r\n";
74+
"Board-ID: " UF2_BOARD_ID "\r\n";
7575

76-
const char indexFile[] = //
76+
const char indexFile[] =
7777
"<!doctype html>\n"
7878
"<html>"
7979
"<body>"
@@ -83,17 +83,17 @@ const char indexFile[] = //
8383
"</body>"
8484
"</html>\n";
8585

86-
// WARNING -- code presumes only one NULL .content for .UF2 file
87-
// and requires it be the last element of the array
8886
static struct TextFile const info[] = {
8987
{.name = "INFO_UF2TXT", .content = infoUf2File},
9088
{.name = "INDEX HTM", .content = indexFile},
91-
{.name = "CURRENT UF2"},
89+
90+
// current.uf2 must be the last element and its content must be NULL
91+
{.name = "CURRENT UF2", .content = NULL},
9292
};
9393

94-
// WARNING -- code presumes each non-UF2 file content fits in single sector
95-
// Cannot programmatically statically assert .content length
96-
// for each element above.
94+
// code presumes each non-UF2 file content fits in single sector
95+
// Cannot programmatically statically assert .content length
96+
// for each element above.
9797
STATIC_ASSERT(ARRAY_SIZE(indexFile) < 512);
9898

9999

@@ -180,7 +180,24 @@ static inline bool in_uicr_space(uint32_t addr)
180180

181181
void uf2_init(void)
182182
{
183-
// nothing to do
183+
strcat(infoUf2File, "SoftDevice: ");
184+
185+
if ( is_sd_existed() )
186+
{
187+
uint32_t const sd_id = SD_ID_GET(MBR_SIZE);
188+
uint32_t const sd_version = SD_VERSION_GET(MBR_SIZE);
189+
190+
uint32_t const ver1 = sd_version / 1000000;
191+
uint32_t const ver2 = (sd_version % 1000000)/1000;
192+
uint32_t const ver3 = sd_version % 1000;
193+
194+
sprintf(infoUf2File + strlen(infoUf2File), "S%lu version %lu.%lu.%lu\r\n", sd_id, ver1, ver2, ver3);
195+
}else
196+
{
197+
strcat(infoUf2File, "not found\r\n");
198+
}
199+
200+
strcat(infoUf2File, "Date: " __DATE__ "\r\n");
184201
}
185202

186203
/*------------------------------------------------------------------*/
@@ -258,9 +275,7 @@ void read_block(uint32_t block_no, uint8_t *data) {
258275
d->updateTime = __DOSTIME__;
259276
d->updateDate = __DOSDATE__;
260277
d->startCluster = startCluster & 0xFF;
261-
// WARNING -- code presumes only one NULL .content for .UF2 file
262-
// and requires it be the last element of the array
263-
d->size = inf->content ? strlen(inf->content) : UF2_SIZE;
278+
d->size = (inf->content ? strlen(inf->content) : UF2_SIZE);
264279
}
265280

266281
} else {

0 commit comments

Comments
 (0)