4
4
#include "configkeys.h"
5
5
#include "flash_nrf5x.h"
6
6
#include <string.h>
7
+ #include <stdio.h>
7
8
8
9
#include "bootloader_settings.h"
9
10
#include "bootloader.h"
@@ -67,13 +68,12 @@ struct TextFile {
67
68
#define STR0 (x ) #x
68
69
#define STR (x ) STR0(x)
69
70
70
- const char infoUf2File [] = //
71
+ char infoUf2File [128 * 3 ] =
71
72
"UF2 Bootloader " UF2_VERSION "\r\n"
72
73
"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" ;
75
75
76
- const char indexFile [] = //
76
+ const char indexFile [] =
77
77
"<!doctype html>\n"
78
78
"<html>"
79
79
"<body>"
@@ -83,17 +83,17 @@ const char indexFile[] = //
83
83
"</body>"
84
84
"</html>\n" ;
85
85
86
- // WARNING -- code presumes only one NULL .content for .UF2 file
87
- // and requires it be the last element of the array
88
86
static struct TextFile const info [] = {
89
87
{.name = "INFO_UF2TXT" , .content = infoUf2File },
90
88
{.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 },
92
92
};
93
93
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.
97
97
STATIC_ASSERT (ARRAY_SIZE (indexFile ) < 512 );
98
98
99
99
@@ -180,7 +180,24 @@ static inline bool in_uicr_space(uint32_t addr)
180
180
181
181
void uf2_init (void )
182
182
{
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" );
184
201
}
185
202
186
203
/*------------------------------------------------------------------*/
@@ -258,9 +275,7 @@ void read_block(uint32_t block_no, uint8_t *data) {
258
275
d -> updateTime = __DOSTIME__ ;
259
276
d -> updateDate = __DOSDATE__ ;
260
277
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 );
264
279
}
265
280
266
281
} else {
0 commit comments