diff --git a/bootloader.c b/bootloader.c index c27550a..b34d264 100644 --- a/bootloader.c +++ b/bootloader.c @@ -21,10 +21,11 @@ error_code status; -char okk[4] = "OK\r\n"; -char errr[5] = "ERR\r\n"; - - +/* +is_even_assembly: + ldr sp, [r0] + ret +*/ char* argvs[3][10]; @@ -58,6 +59,7 @@ int main(void) { crc_prog = uart_string_to_int(cmd.argv[3]); total_size = uart_string_to_int(cmd.argv[2]); offset = uart_string_to_int(cmd.argv[1]); + SCB->VTOR = offset; crc_data = uart_commands_prog(&status, total_size); offset_pointer = offset; diff --git a/uart_commands.c b/uart_commands.c index c44cc43..2b87628 100644 --- a/uart_commands.c +++ b/uart_commands.c @@ -5,9 +5,103 @@ static uint8_t data[1024]; char OK[5] = "OK\r\n"; char ERR[6] = "ERR\r\n"; -void digit_to_str(char* str, uint32_t number){ +void digit_to_str(char* str, uint32_t number, int base){ itoa(number,str,16); } +/* +void digit_to_str(char* str, uint32_t number, int base){ + char tmp_char[32]; + uint32_t tmp = number; + int tmp_counter = 0; + for(int i = 0; i<32; i++); + switch (tmp & 15) + { + case 0: + tmp_char[tmp_counter] = '0'; + tmp_counter++; + tmp=tmp/base; + break; + case 1: + tmp_char[tmp_counter] = '1'; + tmp_counter++; + tmp=tmp/base; + break; + case 2: + tmp_char[tmp_counter] = '2'; + tmp_counter++; + tmp=tmp/base; + break; + case 3: + tmp_char[tmp_counter] = '3'; + tmp_counter++; + tmp=tmp/base; + break; + case 4: + tmp_char[tmp_counter] = '4'; + tmp_counter++; + tmp=tmp/base; + break; + case 5: + tmp_char[tmp_counter] = '5'; + tmp_counter++; + tmp=tmp/base; + break; + case 6: + tmp_char[tmp_counter] = '6'; + tmp_counter++; + tmp=tmp/base; + break; + case 7: + tmp_char[tmp_counter] = '7'; + tmp_counter++; + tmp=tmp/base; + break; + case 8: + tmp_char[tmp_counter] = '8'; + tmp_counter++; + tmp=tmp/base; + break; + case 9: + tmp_char[tmp_counter] = '9'; + tmp_counter++; + tmp=tmp/base; + break; + case 10: + tmp_char[tmp_counter] = 'a'; + tmp_counter++; + tmp=tmp/base; + break; + case 11: + tmp_char[tmp_counter] = 'b'; + tmp_counter++; + tmp=tmp/base; + break; + case 12: + tmp_char[tmp_counter] = 'c'; + tmp_counter++; + tmp=tmp/base; + break; + case 13: + tmp_char[tmp_counter] = 'd'; + tmp_counter++; + tmp=tmp/base; + break; + case 14: + tmp_char[tmp_counter] = 'e'; + tmp_counter++; + tmp=tmp/base; + break; + case 15: + tmp_char[tmp_counter] = 'f'; + tmp_counter++; + tmp=tmp/base; + break; + } + for(int i = 0; i