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)
31 ao_put_string(__code char *s)
44 ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
59 if ('0' <= n && n <= '9')
61 else if ('a' <= n && n <= 'f')
63 else if ('A' <= n && n <= 'F')
76 uint32_t addr = ao_get_hex32();
77 void *p = (void *) addr;
79 ao_flash_erase_page(p);
85 uint32_t addr = ao_get_hex32();
86 void *p = (void *) addr;
90 if (addr < (uint32_t) AO_BOOT_APPLICATION_BASE) {
91 ao_put_string("Invalid address\n");
94 for (i = 0; i < 256; i++)
95 data[i] = ao_usb_getchar();
96 ao_flash_page(p, (void *) data);
102 uint32_t addr = ao_get_hex32();
103 uint8_t *p = (uint8_t *) addr;
107 for (i = 0; i < 256; i++) {
114 ao_show_version(void)
116 ao_put_string("altos-loader");
117 ao_put_string("\nmanufacturer "); ao_put_string(ao_manufacturer);
118 ao_put_string("\nproduct "); ao_put_string(ao_product);
119 ao_put_string("\nsoftware-version "); ao_put_string(ao_version);
124 ao_flash_task(void) {
127 switch (ao_usb_getchar()) {
128 case 'v': ao_show_version(); break;
129 case 'a': ao_application(); break;
130 case 'X': ao_block_erase(); break;
131 case 'W': ao_block_write(); break;
132 case 'R': ao_block_read(); break;