Hardware Design: SIE
Sign in or create your account | Project List | Help
Hardware Design: SIE Git Source Tree
Root/
| 1 | /** |
| 2 | * Primitive first stage bootloader |
| 3 | * |
| 4 | * |
| 5 | */ |
| 6 | #include "soc-hw.h" |
| 7 | |
| 8 | |
| 9 | |
| 10 | void hexprint(unsigned int hexval) |
| 11 | { |
| 12 | unsigned char digit[8]; |
| 13 | int pos; |
| 14 | uart_putstr("0x"); |
| 15 | for(pos = 0; pos < 8; pos++) |
| 16 | { |
| 17 | digit[pos] = (hexval & 0x0F); /* last hexit */ |
| 18 | hexval = hexval >> 4; |
| 19 | } |
| 20 | for(pos = 7; pos > -1; pos--) |
| 21 | { |
| 22 | if( digit[pos] < 0x0A) |
| 23 | uart_putchar(digit[pos] + '0' ); |
| 24 | else |
| 25 | uart_putchar(digit[pos] + 'A' - 10); |
| 26 | } |
| 27 | uart_putchar('.'); |
| 28 | } |
| 29 | |
| 30 | |
| 31 | int main(int argc, char **argv) |
| 32 | { |
| 33 | int8_t *p; |
| 34 | uint8_t c; |
| 35 | unsigned int key, len, autoboot = 1, dispmenu = 1; |
| 36 | |
| 37 | // Initialize UART |
| 38 | uart_init(); |
| 39 | |
| 40 | while(1){ /* loop forever until u-boot gets booted or the board is reset */ |
| 41 | if(dispmenu){ |
| 42 | uart_putstr("\n1: Upload program to RAM\r\n"); |
| 43 | // uart_putstr("2: Upload u-boot to Dataflash\r\n"); |
| 44 | // uart_putstr("3: Upload Kernel to Dataflash\r\n"); |
| 45 | // uart_putstr("4: Start u-boot\r\n"); |
| 46 | // uart_putstr("5: Upload Filesystem image\r\n"); |
| 47 | // uart_putstr("6: Memory test\r\n"); |
| 48 | dispmenu = 0; |
| 49 | } |
| 50 | key = uart_getchar(); |
| 51 | autoboot = 0; |
| 52 | if(key == '1'){ |
| 53 | len = rxmodem((unsigned char *)0x800); |
| 54 | uart_putstr("Received "); |
| 55 | hexprint(len); |
| 56 | uart_putstr(" bytes\r\n"); |
| 57 | // jump(0x1000); |
| 58 | dispmenu = 1; |
| 59 | } |
| 60 | else{ |
| 61 | uart_putstr("Invalid input\r\n"); |
| 62 | dispmenu = 1; |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 |
Branches:
master
