Skip to content

Commit

Permalink
fiddling around to get flash size but nothing actually helps
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrr committed Feb 4, 2025
1 parent e4b6daf commit 875e54e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/daplink-pico/board/rp2350/program_flash_generic_rp2350.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ extern char __stop_for_target_connect_rp2350[];
0.183 ( 0) - - e: 32236
#endif

// ---------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
//
// Functions running in the target
//
Expand Down Expand Up @@ -217,34 +217,33 @@ FOR_TARGET_RP2350_CODE __attribute__((naked)) void rp2350_breakpoint(void)
} // rp2350_breakpoint


#define RT_FLAG_FUNC_ARM_SEC 0x0004
#define RT_FLAG_FUNC_ARM_NONSEC 0x0010
typedef uint16_t *(*rp2350_rom_table_lookup_fn)(uint32_t code, uint32_t mask);

FOR_TARGET_RP2350_CODE static void *rp2350_rom_table_lookup(char c1, char c2)
/**
* Lookup ROM table.
* This seems to have one more indirection as documented.
*/
{
typedef uint16_t (*rp2350_rom_table_lookup_fn)(uint32_t code, uint32_t mask);
uint32_t addr;
const uint32_t BOOTROM_TABLE_LOOKUP_OFFSET = 0x18;
rp2350_rom_table_lookup_fn rom_table_lookup;

rom_table_lookup = (rp2350_rom_table_lookup_fn) (uintptr_t)(*(uint16_t*) (BOOTROM_TABLE_LOOKUP_OFFSET));
const uint32_t BOOTROM_TABLE_LOOKUP_OFFSET = 0x16;
const uint16_t RT_FLAG_FUNC_ARM_SEC = 0x0004;
//const uint16_t RT_FLAG_FUNC_ARM_NONSEC = 0x0010;
rp2350_rom_table_lookup_fn rom_table_lookup = (rp2350_rom_table_lookup_fn) (uintptr_t)(*(uint16_t*) (BOOTROM_TABLE_LOOKUP_OFFSET));

uint16_t code = (c2 << 8) | c1;
addr = *rom_table_lookup(code, RT_FLAG_FUNC_ARM_SEC);
addr = rom_table_lookup(code, RT_FLAG_FUNC_ARM_SEC);
return (void *)addr;
} // rp2350_rom_table_lookup



FOR_TARGET_RP2350_CODE static uint32_t rp2350_flash_size(void)
{
uint32_t buff[2];
int r;
rp2350_rom_get_sys_info_fn sys_info = rp2350_rom_table_lookup('G', 'S');
rp2350_rom_connect_internal_flash_fn connect_flash = rp2350_rom_table_lookup('I', 'F');

connect_flash();

r = sys_info(buff, 2, 0x0008);
if (r != 2)
Expand All @@ -255,6 +254,10 @@ FOR_TARGET_RP2350_CODE static uint32_t rp2350_flash_size(void)
} // rp2350_flash_size


//----------------------------------------------------------------------------------------------------------------------
//
// Actual functions
//

static bool rp2350_target_copy_flash_code(void)
{
Expand All @@ -268,7 +271,6 @@ static bool rp2350_target_copy_flash_code(void)
} // rp2350_target_copy_flash_code



uint32_t target_rp2350_get_external_flash_size(void)
{
uint32_t res = 0;
Expand Down
1 change: 1 addition & 0 deletions src/daplink-pico/board/rp2350/target_utils_rp2350.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ typedef void *(*rp2350_rom_void_fn)(void);
typedef void *(*rp2350_rom_flash_erase_fn)(uint32_t addr, size_t count, uint32_t block_size, uint8_t block_cmd);
typedef void *(*rp2350_rom_flash_prog_fn)(uint32_t addr, const uint8_t *data, size_t count);
typedef int (*rp2350_rom_get_sys_info_fn)(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t flags);
typedef void (*rp2350_rom_connect_internal_flash_fn)(void);

uint32_t rp2350_target_find_rom_func(char ch1, char ch2);
bool rp2350_target_call_function(uint32_t addr, uint32_t args[], int argc, uint32_t breakpoint, uint32_t *result);
Expand Down

0 comments on commit 875e54e

Please sign in to comment.