From patchwork Fri May 8 02:34:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Craig Comstock X-Patchwork-Id: 469864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (tmp.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 8D2B51402A0 for ; Fri, 8 May 2015 12:37:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=yahoo.com header.i=@yahoo.com header.b=pFZ/hyji; dkim-atps=neutral Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 6F6046FA4; Fri, 8 May 2015 02:37:56 +0000 (UTC) X-Original-To: baseband-devel@lists.osmocom.org Delivered-To: baseband-devel@lists.osmocom.org Received: from nm31-vm1.bullet.mail.ne1.yahoo.com (nm31-vm1.bullet.mail.ne1.yahoo.com [98.138.229.41]) by lists.osmocom.org (Postfix) with ESMTP id 438076F7C for ; Fri, 8 May 2015 02:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1431052672; bh=p1FLJ5XYFrRbWkslgXazBCTuO8M7fhpNV9sjlClT7CY=; h=Date:From:Reply-To:To:Subject:From:Subject; b=pFZ/hyjingtApLgb0TgDJpkL3w3xMlV9uNhBPs+T311tYlscljoZQd/CF+totwToAbX8OnV4WN6fgIJVDJS357egF0zXz+AgS5BqBIl1BTP5Q8NkZkNj/dZyUaZrVVqzpWi1cDuSQolkIyoifoG4/peez1s8tW0ZfX1LqPiWX9nMgNbYh7upSuh5HJL12plTsfHr5gQxhTncSVUncNeTwK1Uu4SvV4N1g6UqxiWJuabofyKrNzVnD+fr6FOeusKM6Z2ICGEXTs5dkrw3kG5fGEniKg+yPsgL6FFoPiAQJ9VVxudI9rA3OlPU3mTlb6rajmJSIDsgqkCyvzF6oHKB8g== Received: from [127.0.0.1] by nm31.bullet.mail.ne1.yahoo.com with NNFMP; 08 May 2015 02:37:52 -0000 Received: from [98.138.100.116] by nm31.bullet.mail.ne1.yahoo.com with NNFMP; 08 May 2015 02:34:57 -0000 Received: from [98.138.89.167] by tm107.bullet.mail.ne1.yahoo.com with NNFMP; 08 May 2015 02:34:57 -0000 Received: from [127.0.0.1] by omp1023.mail.ne1.yahoo.com with NNFMP; 08 May 2015 02:34:57 -0000 X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 662642.7291.bm@omp1023.mail.ne1.yahoo.com X-YMail-OSG: lxxJwNUVM1lqwsmRa6TllRAnSWAfQfEFaHmqAdJR4alf5O_gDS43uiFxXhDL6Wi hLgslUauR0bMXqaBM.caIwNEffgnSI4_k660hSZM7yZmZVGyWaGNS8ursX2X6VBn24ql1l8ZY6kl 25CS4YF3NGSkdj7whmAY3rjVM86lZ19d7nFf6azbXEzetYwJ32bInMhpfJVwnfydRBH2uXSQO6Gl kQRXHDHElILpI1ah3KmYeS6RdaaAUpFdU31esgrDFybZ7gzdg_jKzqcIswfkawv5b4sYHwIvxhc2 _FjqwO1dvjpwzrtA4qEmFXBk9Ys988oKPj1xGKHSw0hVfSUxexm2WuD6_zCL.Wv1K7lGMe5gdS1I DChgzE3aezdVMcTN5nwgmBfOSCayGPowqtpRETgnLPKarQxhfLUYYswi6Y3T4Hoe1OxTf52lib2w ZDZk_OjumjIMRLoQWsGxMZmyEywa3NtVdIVr0XkykLIoGh7pxVjsQoqHEh.bhisMFXJJuCY4kOYN qF9GVQaM5Q5LuqhpU Received: by 98.138.105.215; Fri, 08 May 2015 02:34:57 +0000 Date: Fri, 8 May 2015 02:34:56 +0000 (UTC) From: Craig Comstock To: Baseband-devel Message-ID: <2019415965.2390591.1431052496602.JavaMail.yahoo@mail.yahoo.com> Subject: patch on jolly/menu for jumper app MIME-Version: 1.0 X-BeenThere: baseband-devel@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OsmocomBB - open source GSM baseband firmware List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Craig Comstock Errors-To: baseband-devel-bounces@lists.osmocom.org Sender: "baseband-devel" Here is a patch for a simple "jumper" app which loads at 0x2000 and which disables the irqs (thought it might help with the nuttx startup error I have) and jumps to 0x10000 (where I have flashed nuttx). I'm submitting a patch to nuttx as well for building nuttx.bin for running in compal_e86 flash. I may have fouled up the patch due to being on jolly/menu. Wasn't sure if you wanted to pull in those changes as well? I've certainly used the menu app with the flashing_new instructions and it seems to work great on my c139. -Craig From 46188c726b70547e7eebcd386a72becfac300597 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Thu, 26 Sep 2013 09:40:23 +0200 Subject: [PATCH 1/2] Menu App to select highram images from phone's flash memory --- src/target/firmware/Makefile | 3 +- src/target/firmware/apps/menu/main.c | 353 ++++++++++++++++++++++++++++++++++ 2 files changed, 355 insertions(+), 1 deletion(-) create mode 100644 src/target/firmware/apps/menu/main.c diff --git a/src/target/firmware/Makefile b/src/target/firmware/Makefile index 42f7ad4..0f4120f 100644 --- a/src/target/firmware/Makefile +++ b/src/target/firmware/Makefile @@ -84,11 +84,12 @@ BOARD_se_j100_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS) # # List of all applications (meant to be overridden on command line) -APPLICATIONS?=hello_world compal_dsp_dump layer1 loader rssi +APPLICATIONS?=hello_world compal_dsp_dump layer1 loader rssi menu # Applications specific env requirements APP_loader_ENVIRONMENTS=compalram highram APP_rssi_ENVIRONMENTS=* -compalram +APP_menu_ENVIRONMENTS=* -highram # Various objects that are currently linked into all applications FLASH_OBJS=flash/cfi_flash.o diff --git a/src/target/firmware/apps/menu/main.c b/src/target/firmware/apps/menu/main.c new file mode 100644 index 0000000..47aadc4 --- /dev/null +++ b/src/target/firmware/apps/menu/main.c @@ -0,0 +1,353 @@ +/* Menu for Calypso Phone to load applicatios from flash */ + +/* (C) 2013 by Andreas Eversberg + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RAM 0x00820000 +#define MAGIC 0x0083ff00 + +enum key_codes key_code = KEY_INV; +static volatile enum key_states key_state; + +int cursor = 0, scroll_apps = 0; + +struct apps { + char name[16]; + void *start; + int len; +} apps[32]; + +int _memcmp(char *s1, char *s2, int size) +{ + int i; + + for (i = 0; i < size; i++) { + if (*s1 < *s2) + return -1; + if (*s1 > *s2) + return 1; + s1++; + s2++; + } + + return 0; +} + +static void locate_apps(void) +{ + int i, j, k; + char *p; + + memset(apps, 0, sizeof(apps)); + + for (j = 0, i = 0x010000; i < 0x200000; i += 0x10000) { + p = (char *)i; + /* check for highram header: "highram:" */ + if (!!_memcmp(p, "highram:", 8)) + continue; + p += 8; + /* check for app name after header: "highram:\n" */ + printf("found highram image at flash mem address 0x%p\n", + (char *)i); + for (k = 0; k < (int)sizeof(apps[j].name) - 1; k++) { + if (p[k] == '\n') + break; + } + if (k == sizeof(apps[j].name) - 3) { + printf("skipping: corrupt highram header, no '\\n' " + "after image name or name more larger than %d " + "digits\n", (int)sizeof(apps[j].name) - 3); + continue; + } + if (j < 9) + apps[j].name[0] = '1' + j; + else if (j == 9) + apps[j].name[0] = '0'; + else + apps[j].name[0] = ' '; + apps[j].name[1] = ' '; + memcpy(apps[j].name + 2, p, k); + apps[j].len = 0x20000; + p += k + 1; + /* p points to highram image after header */ + apps[j].start = p; + j++; + } +} + +static void wait_key_release(void) +{ + /* wait for key release */ + while (key_state == PRESSED) { + delay_ms(10); + keypad_poll(); + } +} + +static void load_app(void) +{ + static int i; + static void (*f) (void) = (void (*)(void))RAM; + + wait_key_release(); + + local_irq_disable(); + + for (i = 0; i < apps[cursor].len; i++) + ((unsigned char *)RAM)[i] = ((unsigned char *)apps[cursor].start)[i]; + f(); +} + +/* UI */ + +static void refresh_display(void) +{ +#if 0 + char text[16]; + int bat = battery_info.battery_percent; +#endif + int i; + + fb_clear(); + + /* header */ + fb_setbg(FB_COLOR_WHITE); + if (1) { + fb_setfg(FB_COLOR_BLUE); + fb_setfont(FB_FONT_HELVR08); + fb_gotoxy(0, 7); + fb_putstr("Osmocom Menu", -1); + fb_setfg(FB_COLOR_RGB(0xc0, 0xc0, 0x00)); + fb_setfont(FB_FONT_SYMBOLS); +#if 0 + fb_gotoxy(framebuffer->width - 15, 8); + if (bat >= 100 && (battery_info.flags & BATTERY_CHG_ENABLED) + && !(battery_info.flags & BATTERY_CHARGING)) + fb_putstr("@HHBC", framebuffer->width); + else { + sprintf(text, "@%c%c%cC", (bat >= 30) ? 'B':'A', + (bat >= 60) ? 'B':'A', (bat >= 90) ? 'B':'A'); + fb_putstr(text, framebuffer->width); + } +#endif + fb_gotoxy(0, 8); + fb_putstr("GGEGG", framebuffer->width); + fb_setfg(FB_COLOR_GREEN); + fb_gotoxy(0, 10); + fb_boxto(framebuffer->width - 1, 10); + } + fb_setfg(FB_COLOR_BLACK); + fb_setfont(FB_FONT_C64); + + + for (i = 0; i < 5; i++) { + if (!apps[scroll_apps + i].name) + break; + if (scroll_apps + i == cursor) { + fb_setfg(FB_COLOR_WHITE); + fb_setbg(FB_COLOR_BLUE); + } + fb_gotoxy(0, 20 + i * 10); + fb_putstr(apps[scroll_apps + i].name, + framebuffer->width); + if (scroll_apps + i == cursor) { + fb_setfg(FB_COLOR_BLACK); + fb_setbg(FB_COLOR_WHITE); + } + } + if (i == 0) { + fb_gotoxy(0, 50); + fb_putstr("No apps!", -1); + } + + fb_flush(); +} + +static void handle_key_code() +{ + if (key_code == KEY_INV) + return; + + switch (key_code) { + case KEY_1: + case KEY_2: + case KEY_3: + case KEY_4: + case KEY_5: + case KEY_6: + case KEY_7: + case KEY_8: + case KEY_9: + if (apps[key_code - KEY_1].len) { + cursor = key_code - KEY_1; + load_app(); + } + break; + case KEY_0: + if (apps[9].len) { + cursor = 9; + load_app(); + } + break; + case KEY_UP: + if (cursor == 0) + return; + cursor--; + if (cursor < scroll_apps) + scroll_apps = cursor; + refresh_display(); + break; + case KEY_DOWN: + if (!apps[cursor + 1].name[0]) + return; + cursor++; + if (cursor >= scroll_apps + 5) + scroll_apps = cursor - 4; + refresh_display(); + break; + case KEY_OK: + if (apps[cursor].len) + load_app(); + break; + case KEY_POWER: + wait_key_release(); + twl3025_power_off(); + break; + default: + break; + } + + key_code = KEY_INV; +} + +/* Main Program */ +const char *hr = "======================================================================\n"; + +static void key_handler(enum key_codes code, enum key_states state) +{ + key_state = state; + + if (state != PRESSED) + return; + + key_code = code; +} + +extern void putchar_asm(uint32_t c); + +static const uint8_t phone_ack[] = { 0x1b, 0xf6, 0x02, 0x00, 0x41, 0x03, 0x42 }; + +int main(void) +{ + int i; + + /* Simulate a compal loader saying "ACK" */ + for (i = 0; i < (int)sizeof(phone_ack); i++) { + putchar_asm(phone_ack[i]); + } + + board_init(0); + + puts("\n\nOsmocomBB Menu (revision " GIT_REVISION ")\n"); + puts(hr); + + fb_clear(); + + fb_setfg(FB_COLOR_BLACK); + fb_setbg(FB_COLOR_WHITE); + fb_setfont(FB_FONT_HELVB14); + + fb_gotoxy(2,20); + fb_putstr("menu",framebuffer->width-4); + + fb_setfg(FB_COLOR_RED); + fb_setbg(FB_COLOR_BLUE); + + fb_gotoxy(2,25); + fb_boxto(framebuffer->width-3,38); + + fb_setfg(FB_COLOR_WHITE); + fb_setfont(FB_FONT_HELVR08); + fb_gotoxy(8,33); + fb_putstr("osmocom-bb",framebuffer->width-4); + + fb_flush(); + + /* Dump device identification */ + dump_dev_id(); + puts(hr); + + /* Dump clock config before PLL set */ + calypso_clk_dump(); + puts(hr); + + keypad_set_handler(&key_handler); + + /* Dump clock config after PLL set */ + calypso_clk_dump(); + puts(hr); + +// display_unset_attr(DISP_ATTR_INVERT); + + locate_apps(); + + while (1) { + for (i = 0; i < 50; i++) { + keypad_poll(); + delay_ms(10); + osmo_timers_update(); + handle_key_code(); + } + refresh_display(); + } + + /* NOT REACHED */ + + twl3025_power_off(); +} + -- 1.7.10.4