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)
30 ao_put_string(__code char *s)
40 ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
55 if ('0' <= n && n <= '9')
57 else if ('a' <= n && n <= 'f')
59 else if ('A' <= n && n <= 'F')
72 uint32_t addr = ao_get_hex32();
73 uint32_t *p = (uint32_t *) addr;
75 ao_flash_erase_page(p);
81 uint32_t addr = ao_get_hex32();
82 uint32_t *p = (uint32_t *) addr;
89 if (addr < 0x08002000 || 0x08200000 <= addr) {
90 ao_put_string("Invalid address\n");
93 for (i = 0; i < 256; i++)
94 u.data8[i] = getchar();
95 ao_flash_page(p, u.data32);
101 uint32_t addr = ao_get_hex32();
102 uint8_t *p = (uint8_t *) addr;
106 for (i = 0; i < 256; i++) {
113 ao_show_version(void)
115 puts("altos-loader");
116 ao_put_string("manufacturer "); puts(ao_manufacturer);
117 ao_put_string("product "); puts(ao_product);
118 ao_put_string("software-version "); puts(ao_version);
122 ao_flash_task(void) {
125 case 'v': ao_show_version(); break;
126 case 'a': ao_application(); break;
127 case 'X': ao_block_erase(); break;
128 case 'W': ao_block_write(); break;
129 case 'R': ao_block_read(); break;