2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 #include <ao_flash_stm.h>
25 ao_panic(uint8_t reason)
33 ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
39 __pdata uint8_t r = ao_cmd_lex_error;
45 n = ao_cmd_hexchar(ao_cmd_lex_c);
52 if (r != ao_cmd_success)
60 uint32_t addr = ao_cmd_hex32();
61 uint32_t *p = (uint32_t *) addr;
63 ao_flash_erase_page(p);
69 uint32_t addr = ao_cmd_hex32();
70 uint32_t *p = (uint32_t *) addr;
77 if (addr < 0x08002000 || 0x08200000 <= addr) {
78 puts("Invalid address");
81 for (i = 0; i < 256; i++)
83 ao_flash_page(p, u.data32);
100 uint32_t addr = ao_cmd_hex32();
101 uint8_t *p = (uint8_t *) addr;
105 for (i = 0; i < 256; i++) {
109 if ((i & 0xf) == 0xf)
114 __code struct ao_cmds ao_flash_cmds[] = {
115 { ao_application, "a\0Switch to application" },
116 { ao_block_erase, "e <addr>\0Erase block." },
117 { ao_block_write, "W <addr>\0Write block. 256 binary bytes follow newline" },
118 { ao_block_read, "R <addr>\0Read block. Returns 256 bytes" },
134 c = ao_usb_getchar();
140 struct ao_task ao_test_task;
141 >>>>>>> 5187bb4... Add STM self-flashing loader
152 >>>>>>> 5187bb4... Add STM self-flashing loader
160 ao_cmd_register(&ao_flash_cmds[0]);
162 >>>>>>> 5187bb4... Add STM self-flashing loader
163 ao_start_scheduler();