Skip to content

Commit 5276f48

Browse files
committed
update multi booter
switch order of picomite and sd_boot to make more space for progs of multi booter bin folder name changed to firmware ui interface improvments
1 parent 3009ce7 commit 5276f48

File tree

11 files changed

+102
-58
lines changed

11 files changed

+102
-58
lines changed

Code/pico_multi_booter/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ add_custom_target(BUILT_${BOOT}
7272

7373
add_dependencies(BUILT_boot boot)
7474

75-
add_dependencies(PREPARE_picomite BUILT_boot)
76-
add_dependencies(picomite PREPARE_picomite)
77-
add_dependencies(BUILT_picomite picomite)
78-
79-
add_dependencies(PREPARE_sd_boot BUILT_picomite)
75+
add_dependencies(PREPARE_sd_boot BUILT_boot)
8076
add_dependencies(sd_boot PREPARE_sd_boot)
8177
add_dependencies(BUILT_sd_boot sd_boot)
8278

79+
add_dependencies(PREPARE_picomite BUILT_sd_boot)
80+
add_dependencies(picomite PREPARE_picomite)
81+
add_dependencies(BUILT_picomite picomite)
82+
8383

8484
# ***************************************************************************
8585
# * Join the BOOT and all APP '.uf2' files together *
8686
# ***************************************************************************
87-
set(UF2S boot.uf2 picomite.uf2 sd_boot.uf2)
87+
set(UF2S boot.uf2 sd_boot.uf2 picomite.uf2)
8888

8989
add_custom_target(JOIN
9090
COMMENT "Combine the '.uf2' files"
@@ -95,7 +95,7 @@ add_custom_target(JOIN
9595
${UF2S}
9696
)
9797

98-
add_dependencies(JOIN BUILT_sd_boot)
98+
add_dependencies(JOIN BUILT_picomite)
9999

100100
add_custom_target(${PROJECT} ALL DEPENDS JOIN)
101101

Code/pico_multi_booter/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Here is a bootloader for PicoCalc combined slightly modified [PicoMite](https://github.com/madcock/PicoMiteAllVersions) and [SD boot](https://github.com/adwuard/Picocalc_SD_Boot)
44

55
- Pico1
6-
- No sdcard inserted ,PicoMite will show up.
7-
- Sdcard inserted, SD boot menu will show up, load third pico app bin to run at FLASH TARGET OFFSET 2048k-940k
6+
- No sdcard inserted,load default app to run from flash.
7+
- Sdcard inserted, SD boot menu will show up, load third pico app bin to run at FLASH TARGET OFFSET 2048k-152k
88

99
## How to compile
1010
```
@@ -29,13 +29,13 @@ configuration.h
2929

3030
config.h
3131
```
32-
#define SD_BOOT_FLASH_OFFSET (940 * 1024)
32+
#define SD_BOOT_FLASH_OFFSET (152 * 1024)
3333
```
3434

3535
### SD Card Application Build and Deployment
3636
**Important Note:**
3737
```
38-
Applications intended for SD card boot "MUST REBUILD" using a custom linker script to accommodate the program's offset(940k) address.
38+
Applications intended for SD card boot "MUST REBUILD" using a custom linker script to accommodate the program's offset(152k) address.
3939
4040
Applications intended for SD card boot is in **bin** format, not uf2.
4141
@@ -81,7 +81,7 @@ make
8181
```
8282

8383
#### Step 3 Your Custom Application Is Ready For SD Card Boot
84-
Once the build is complete, copy the generated `.bin` file to the `/sd` directory of the SD card.
84+
Once the build is complete, copy the generated `.bin` file to the `/firmware` directory of the SD card.
8585

8686

8787

Code/pico_multi_booter/boot.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ int main(void) {
150150
printf("max %d \n",max);
151151

152152
// Choose an app to launch
153+
/*
153154
int chosen;
154155
if(!sd_card_inserted()){
155156
printf("No sd card\n");
@@ -159,7 +160,8 @@ int main(void) {
159160
chosen = max-1;
160161
if(chosen <0 ) chosen = 0;
161162
}
162-
163+
*/
164+
int chosen = 0;
163165
// Get start address of app
164166
addr = PEEK32( info + ((chosen * 16)));
165167
printf("Application at %08lX\n", addr);

Code/pico_multi_booter/linker_scripts/memmap_default.ld.mp.rp2040

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*arduino-pico*/
22
MEMORY
33
{
4-
FLASH(rx) : ORIGIN = 0x10000000 + 940k, LENGTH = __FLASH_LENGTH__ - 940k
4+
FLASH(rx) : ORIGIN = 0x10000000 + 152k, LENGTH = __FLASH_LENGTH__ - 152k
55
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = __RAM_LENGTH__
66
SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
77
SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k

Code/pico_multi_booter/linker_scripts/memmap_mp_rp2040.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
MEMORY
2626
{
27-
FLASH(rx) : ORIGIN = 0x10000000 + 940k, LENGTH = 2048k - 940k
27+
FLASH(rx) : ORIGIN = 0x10000000 + 152k, LENGTH = 2048k - 152k
2828
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
2929
SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
3030
SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k

Code/pico_multi_booter/linker_scripts/rpi-pico.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
MEMORY
66
{
7-
FLASH(rx) : ORIGIN = 0x10000000 + 940k, LENGTH = 2048k - 940k
7+
FLASH(rx) : ORIGIN = 0x10000000 + 152k, LENGTH = 2048k - 152k
88
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
99
SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
1010
SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k

Code/pico_multi_booter/memmap_default_rp2040.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MEMORY
22
{
3-
FLASH(rx) : ORIGIN = 0x10000000 + 940k, LENGTH = 2048k - 940k
3+
FLASH(rx) : ORIGIN = 0x10000000 + 152k, LENGTH = 2048k - 152k
44
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
55
SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
66
SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k

Code/pico_multi_booter/memmap_default_rp2350.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
MEMORY
2525
{
26-
FLASH(rx) : ORIGIN = 0x10000000 + 940k, LENGTH = 4096k - 940k
26+
FLASH(rx) : ORIGIN = 0x10000000 + 152k, LENGTH = 4096k - 152k
2727
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k
2828
SCRATCH_X(rwx) : ORIGIN = 0x20080000, LENGTH = 4k
2929
SCRATCH_Y(rwx) : ORIGIN = 0x20081000, LENGTH = 4k

Code/pico_multi_booter/sd_boot/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// According to the applink.map ,with combined PicoMite, here is 920k
3737
// This offset is used to ensure that the bootloader does not get overwritten
3838
// when loading a new application from the SD card
39-
#define SD_BOOT_FLASH_OFFSET (940 * 1024)
39+
#define SD_BOOT_FLASH_OFFSET (152 * 1024)
4040

4141
// Maximum size of the application that can be loaded
4242
// This ensures we don't overwrite the bootloader itself

Code/pico_multi_booter/sd_boot/main.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,18 @@ int load_firmware_by_path(const char *path)
207207

208208
// Attempt to load the application from the SD card
209209
// bool load_success = load_program(FIRMWARE_PATH);
210-
bool load_success = load_program(path);
210+
bool load_success=false;
211211

212212
// Get the pointer to the application flash area
213213
uint32_t *app_location = (uint32_t *)(XIP_BASE + SD_BOOT_FLASH_OFFSET);
214-
215214
// Check if there is an already valid application in flash
216215
bool has_valid_app = is_valid_application(app_location);
217216

218-
217+
if(path == NULL) {
218+
load_success = true;
219+
}else{
220+
load_success = load_program(path);
221+
}
219222

220223
if (load_success || has_valid_app)
221224
{
@@ -245,11 +248,21 @@ int load_firmware_by_path(const char *path)
245248

246249
void final_selection_callback(const char *path)
247250
{
251+
char status_message[128];
252+
const char *extension = ".bin";
253+
if(path == NULL) {
254+
//load default app from flash
255+
256+
snprintf(status_message, sizeof(status_message), "SEL: %s", "FLASH+152k");
257+
text_directory_ui_set_status(status_message);
258+
sleep_ms(200);
259+
load_firmware_by_path(path);
260+
return;
261+
}
248262
// Trigger firmware loading with the selected path
249263
DEBUG_PRINT("selected: %s\n", path);
250264

251-
char status_message[128];
252-
const char *extension = ".bin";
265+
253266
size_t path_len = strlen(path);
254267
size_t ext_len = strlen(extension);
255268

@@ -286,7 +299,6 @@ int main()
286299
keypad_init();
287300
lcd_init();
288301
lcd_clear();
289-
text_directory_ui_init();
290302

291303
// Check for SD card presence
292304
DEBUG_PRINT("Checking for SD card...\n");

0 commit comments

Comments
 (0)