5#include "bootrom_rp2040.h"
8using namespace _IO_QSPI_;
9using namespace _XIP_SSI_;
12bootrom_rp2040::rom_header_t * bootrom_rp2040::_rom_header {0x00000000};
13uint8_t bootrom_rp2040::_rx_buffer[13] {0};
14uint8_t bootrom_rp2040::_tx_buffer[13] {0};
15uint32_t bootrom_rp2040::_boot2_copy[64];
17std::array<uint8_t, 8> COPY_TO_RAM bootrom_rp2040::read_unique_id() {
20 for(
size_t i=0; i < 64; ++i) {
21 _boot2_copy[i] = *(((uint32_t *)0x10000000) + i);
25 asm volatile(
"" : : :
"memory");
27 bootrom_rp2040::connect_internal_flash();
28 bootrom_rp2040::flash_exit_xip();
31 IO_QSPI.GPIO_QSPI_SS_CTRL.OUTOVER = GPIO_QSPI_SS_CTRL_OUTOVER__LOW;
33 for (
int i=0; i < 13; ++i) _rx_buffer[i] = _tx_buffer[i] = 0;
37 while (tx_idx < 13 || rx_idx < 13) {
38 if (XIP_SSI.SR.TFNF) {
39 XIP_SSI.DR0 = _tx_buffer[tx_idx++];
41 if (XIP_SSI.SR.RFNE) {
42 _rx_buffer[rx_idx++] = XIP_SSI.DR0;
46 IO_QSPI.GPIO_QSPI_SS_CTRL.OUTOVER = GPIO_QSPI_SS_CTRL_OUTOVER__HIGH;
48 bootrom_rp2040::flash_flush_cache();
50 ((void (*)(void))((intptr_t)_boot2_copy+1))();
54 std::array<uint8_t, 8> arr {0};
55 for(
int i=5; i < 13; ++i) arr[i-5] = _rx_buffer[i];
59std::array<char, 17> bootrom_rp2040::read_unique_id_string() {
60 auto id = read_unique_id();
61 std::array<char, 17> res {0};
63 for(uint8_t & c :
id) {
65 res[res_index++] = n > 9 ? n+
'A'-10 : n+
'0';
67 res[res_index++] = n > 9 ? n+
'A'-10 : n+
'0';
CMSIS-Core(M) Device Peripheral Access Layer Header File for Device RP2040.