2 * Copyright © 2013 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_task.h>
25 ao_panic(uint8_t reason)
30 ao_put_string(__code char *s)
43 ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
58 if ('0' <= n && n <= '9')
60 else if ('a' <= n && n <= 'f')
62 else if ('A' <= n && n <= 'F')
75 uint32_t addr = ao_get_hex32();
76 uint32_t *p = (uint32_t *) addr;
78 ao_flash_erase_page(p);
84 uint32_t addr = ao_get_hex32();
85 uint32_t *p = (uint32_t *) addr;
92 if (addr < (uint32_t) AO_BOOT_APPLICATION_BASE) {
93 ao_put_string("Invalid address\n");
96 for (i = 0; i < 256; i++)
97 u.data8[i] = ao_usb_getchar();
98 ao_flash_page(p, u.data32);
104 uint32_t addr = ao_get_hex32();
105 uint8_t *p = (uint8_t *) addr;
109 for (i = 0; i < 256; i++) {
116 ao_show_version(void)
118 ao_put_string("altos-loader");
119 ao_put_string("\nmanufacturer "); ao_put_string(ao_manufacturer);
120 ao_put_string("\nproduct "); ao_put_string(ao_product);
121 ao_put_string("\nsoftware-version "); ao_put_string(ao_version);
126 ao_flash_task(void) {
129 switch (ao_usb_getchar()) {
130 case 'v': ao_show_version(); break;
131 case 'a': ao_application(); break;
132 case 'X': ao_block_erase(); break;
133 case 'W': ao_block_write(); break;
134 case 'R': ao_block_read(); break;