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.
21 #include <ao_flash_stm.h>
24 ao_panic(uint8_t reason)
32 ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
38 __pdata uint8_t r = ao_cmd_lex_error;
44 n = ao_cmd_hexchar(ao_cmd_lex_c);
51 if (r != ao_cmd_success)
59 uint32_t addr = ao_cmd_hex32();
60 uint32_t *p = (uint32_t *) addr;
62 ao_flash_erase_page(p);
68 uint32_t addr = ao_cmd_hex32();
69 uint32_t *p = (uint32_t *) addr;
76 if (addr < 0x08002000 || 0x08200000 <= addr) {
77 ao_put_string("Invalid address\n");
80 for (i = 0; i < 256; i++)
81 u.data8[i] = getchar();
82 ao_flash_page(p, u.data32);
99 uint32_t addr = ao_cmd_hex32();
100 uint8_t *p = (uint8_t *) addr;
104 for (i = 0; i < 256; i++) {
106 (*ao_stdios[ao_cur_stdio].putchar)(c);
111 ao_block_read_hex(void)
113 uint32_t addr = ao_cmd_hex32();
114 uint8_t *p = (uint8_t *) addr;
118 for (i = 0; i < 256; i++) {
122 if ((i & 0xf) == 0xf)
128 ao_show_version(void)
130 puts("altos-loader");
131 ao_put_string("manufacturer "); puts(ao_manufacturer);
132 ao_put_string("product "); puts(ao_product);
133 ao_put_string("software-version "); puts(ao_version);
136 __code struct ao_cmds ao_flash_cmds[] = {
137 { ao_show_version, "v\0Version" },
138 { ao_application, "a\0Switch to application" },
139 { ao_block_erase, "X <addr>\0Erase block." },
140 { ao_block_write, "W <addr>\0Write block. 256 binary bytes follow newline" },
141 { ao_block_read, "R <addr>\0Read block. Returns 256 binary bytes" },
142 { ao_block_read_hex, "H <addr>\0Hex read block. Returns 256 bytes in hex" },
160 ao_cmd_register(&ao_flash_cmds[0]);
161 ao_start_scheduler();