mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-23 00:38:33 +03:00
HACK: Add EEPROM writing at boot of SAM3 on qmod
This is not for production use, but just for hardware verification
This commit is contained in:
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
/** UART0 */
|
/** UART0 */
|
||||||
/** Console baudrate always using 115200. */
|
/** Console baudrate always using 115200. */
|
||||||
#define CONSOLE_BAUDRATE 230400
|
#define CONSOLE_BAUDRATE 115200
|
||||||
/** Usart Hw interface used by the console (UART0). */
|
/** Usart Hw interface used by the console (UART0). */
|
||||||
#define CONSOLE_USART UART0
|
#define CONSOLE_USART UART0
|
||||||
/** Usart Hw ID used by the console (UART0). */
|
/** Usart Hw ID used by the console (UART0). */
|
||||||
|
|||||||
@@ -133,24 +133,72 @@ extern int main(void)
|
|||||||
g_unique_id[2], g_unique_id[3]);
|
g_unique_id[2], g_unique_id[3]);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
|
static const unsigned char __eeprom_bin[] = {
|
||||||
|
0x23, 0x42, 0x17, 0x25, 0x00, 0x00, 0x9b, 0x20, 0x01, 0xa0, 0x00, 0x5e,
|
||||||
|
0x01, 0x32, 0x01, 0x32, 0x32, 0x04, 0x09, 0x18, 0x0d, 0x00, 0x73, 0x00,
|
||||||
|
0x79, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x6f, 0x00,
|
||||||
|
0x6d, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x73, 0x00, 0x2e, 0x00,
|
||||||
|
0x66, 0x00, 0x2e, 0x00, 0x6d, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x2e, 0x00,
|
||||||
|
0x20, 0x00, 0x47, 0x00, 0x6d, 0x00, 0x62, 0x00, 0x48, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x71, 0x00, 0x75, 0x00, 0x61, 0x00, 0x64, 0x00, 0x20, 0x00, 0x6d, 0x00,
|
||||||
|
0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x20, 0x00, 0x76, 0x00,
|
||||||
|
0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
static const unsigned int __eeprom_bin_len = 256;
|
||||||
|
|
||||||
static const Pin pin_hub_rst = {PIO_PA13, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT};
|
static const Pin pin_hub_rst = {PIO_PA13, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT};
|
||||||
PIO_Configure(&pin_hub_rst, 1);
|
PIO_Configure(&pin_hub_rst, 1);
|
||||||
i2c_pin_init();
|
i2c_pin_init();
|
||||||
while (1) {
|
|
||||||
for (i = 0; i < 256; i ++) {
|
/* wait */
|
||||||
int byte = eeprom_read_byte(0x50, i);
|
volatile int v;
|
||||||
TRACE_INFO("0x%02x: %02x\r\n", i, byte);
|
/* 440ns per cycle here */
|
||||||
}
|
for (i = 0; i < 1000000; i++) {
|
||||||
|
v = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* write the EEPROM once */
|
||||||
|
for (i = 0; i < 256; i++) {
|
||||||
|
int rc = eeprom_write_byte(0x50, i, __eeprom_bin[i]);
|
||||||
|
/* if the result was negative, repeat that write */
|
||||||
|
if (rc < 0)
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* then pursue re-reading it again and again */
|
||||||
|
for (i = 0; i < 256; i++) {
|
||||||
|
int byte = eeprom_read_byte(0x50, i);
|
||||||
|
TRACE_INFO("0x%02x: %02x\r\n", i, byte);
|
||||||
|
if (byte != __eeprom_bin[i])
|
||||||
|
TRACE_ERROR("Byte %u is wrong, expected 0x%02x, found 0x%02x\r\n",
|
||||||
|
i, __eeprom_bin[i], byte);
|
||||||
|
}
|
||||||
|
PIO_Clear(&pin_hub_rst);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TRACE_INFO("USB init...\r\n");
|
TRACE_INFO("USB init...\r\n");
|
||||||
while (USBD_GetState() < USBD_STATE_CONFIGURED) {
|
while (USBD_GetState() < USBD_STATE_CONFIGURED) {
|
||||||
|
#if 0
|
||||||
if (i >= MAX_USB_ITER * 3) {
|
if (i >= MAX_USB_ITER * 3) {
|
||||||
TRACE_ERROR("Resetting board (USB could "
|
TRACE_ERROR("Resetting board (USB could "
|
||||||
"not be configured)\r\n");
|
"not be configured)\r\n");
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user