/** * Primitive first stage bootloader * * */ #include "soc-hw.h" /* prototypes */ uint32_t read_uint32() { uint32_t val = 0, i; for (i = 0; i < 4; i++) { val <<= 8; val += (uint8_t)uart_getchar(); } return val; } void hexprint(unsigned int hexval) { int digit[8], pos; uart_putstr("0x"); for(pos = 0; pos < 8; pos++) { digit[pos] = (hexval & 0xF); /* last hexit */ hexval = hexval >> 4; } for(pos = 7; pos > -1; pos--) { if(digit[pos] < 0xA) uart_putstr((char *)digit[pos] + '0'); else uart_putstr((char *)digit[pos] + 'A' - 10); } uart_putchar(' '); } int main(int argc, char **argv) { int8_t *p; uint8_t c; int key, len, autoboot = 1, dispmenu = 1; // Initialize UART uart_init(); while(1){ /* loop forever until u-boot gets booted or the board is reset */ if(dispmenu){ uart_putstr("\n1: Upload program to RAM\r\n"); // uart_putstr("2: Upload u-boot to Dataflash\r\n"); // uart_putstr("3: Upload Kernel to Dataflash\r\n"); // uart_putstr("4: Start u-boot\r\n"); // uart_putstr("5: Upload Filesystem image\r\n"); // uart_putstr("6: Memory test\r\n"); dispmenu = 0; } key = uart_getchar(); autoboot = 0; if(key == '1'){ len = rxmodem((unsigned char *)0x800); uart_putstr("Received "); hexprint(len); uart_putstr(" bytes\r\n"); // jump(0x1000); dispmenu = 1; } else{ uart_putstr("Invalid input\r\n"); dispmenu = 1; } } }