Hi all,
I've been trying to join the party with my OpenMoko GTA02, and I found that a few tweaks were required.
Patch 1/4 was required to get the romloader to start, otherwise osmocon would only receive an occasional '\x00' character instead of the ident_cmd. It works perfectly with the beacon interval reduced to 13 mS, but I've made it configurable just in case other targets don't like it.
Patches 2/4 and 3/4 are bugfixes for the calypso uart code. The LCR register ended up being clobbered, and this rendered the uart on my board silent.
Finally, I'm using the GTA02 AP as the "host", communicating via the internal ttySAC0 UART. Patch 4/4 allowed me to cross-compile osmocon & friends on my x86 box with the AP ARM as the target.
Now I can run,
./osmocon -m romload -p /dev/ttySAC0 -i 13 -d tr firmware/layer1.highram.bin
while toggling power via,
echo 0 >/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on echo 1 >/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on
and get:
OSMOCOM Layer 1 (revision osmocon_v0.0.0-696-ge801cee-modified) ====================================================================== Device ID code: 0xb496 Device Version code: 0x0000 ARM ID code: 0xfff3 cDSP ID code: 0x0128 Die ID code: e4942219e4949b52 ====================================================================== REG_DPLL=0x2413 CNTL_ARM_CLK=0xf0a1 CNTL_CLK=0xff91 CNTL_RST=0xfff3 CNTL_ARM_DIV=0xfff9 ======================================================================
Cheers, Alex
Alex Badea (4): osmocon: make beacon interval configurable via cmdline target uart: fix preservation of LCR target uart: remove REG_OFFS() macro side-effect toplevel Makefile: accept arguments for host ./configure calls
src/Makefile | 8 ++++---- src/host/osmocon/osmocon.c | 26 ++++++++++++++++---------- src/target/firmware/calypso/uart.c | 10 +++++----- 3 files changed, 25 insertions(+), 19 deletions(-)
Beacons with the default 50 mS interval are too far apart to be picked up by the OpenMoko gta0x Calypso chip. Make them configurable via a -i commandline argument.
As recommended in the OpenMoko wiki[1], an interval of 13 mS works.
[1] http://wiki.openmoko.org/wiki/GSM/Flashing (-od fluid argument)
Signed-off-by: Alex Badea vamposdecampos@gmail.com --- src/host/osmocon/osmocon.c | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c index 024697d..6f6f566 100644 --- a/src/host/osmocon/osmocon.c +++ b/src/host/osmocon/osmocon.c @@ -51,7 +51,7 @@ #define MAX_HDR_SIZE 128 #define MAGIC_OFFSET 0x3be2
-#define BEACON_INTERVAL 50000 +#define DEFAULT_BEACON_INTERVAL 50000 #define ROMLOAD_INIT_BAUDRATE B19200 #define ROMLOAD_DL_BAUDRATE B115200 #define ROMLOAD_BLOCK_HDR_LEN 10 @@ -137,6 +137,7 @@ struct dnload {
int dump_rx; int dump_tx; + int beacon_interval;
/* data to be downloaded */ uint8_t *data; @@ -289,7 +290,7 @@ static void beacon_timer_cb(void *p) if (!(rc == sizeof(romload_ident_cmd))) printf("Error sending identification beacon\n");
- bsc_schedule_timer(p, 0, BEACON_INTERVAL); + bsc_schedule_timer(p, 0, dnload.beacon_interval); } }
@@ -304,7 +305,7 @@ static void mtk_timer_cb(void *p) if (!(rc == 1)) printf("Error sending identification beacon\n");
- bsc_schedule_timer(p, 0, BEACON_INTERVAL); + bsc_schedule_timer(p, 0, dnload.beacon_interval); } }
@@ -888,7 +889,7 @@ static int handle_read(void) serial_set_baudrate(ROMLOAD_INIT_BAUDRATE); tick_timer.cb = &beacon_timer_cb; tick_timer.data = &tick_timer; - bsc_schedule_timer(&tick_timer, 0, BEACON_INTERVAL); + bsc_schedule_timer(&tick_timer, 0, dnload.beacon_interval); } } else if (!memcmp(buffer, phone_nack, sizeof(phone_nack))) { printf("Received DOWNLOAD NACK from phone, something went" @@ -1003,7 +1004,7 @@ static int handle_read_romload(void) "something went wrong, aborting\n"); serial_set_baudrate(ROMLOAD_INIT_BAUDRATE); dnload.romload_state = WAITING_IDENTIFICATION; - bsc_schedule_timer(&tick_timer, 0, BEACON_INTERVAL); + bsc_schedule_timer(&tick_timer, 0, dnload.beacon_interval); } break; case WAITING_CHECKSUM_ACK: @@ -1025,7 +1026,7 @@ static int handle_read_romload(void) "match ours, aborting\n", ~buffer[2]); serial_set_baudrate(ROMLOAD_INIT_BAUDRATE); dnload.romload_state = WAITING_IDENTIFICATION; - bsc_schedule_timer(&tick_timer, 0, BEACON_INTERVAL); + bsc_schedule_timer(&tick_timer, 0, dnload.beacon_interval); bufptr -= 1; } break; @@ -1042,7 +1043,7 @@ static int handle_read_romload(void) printf("Received branch nack, aborting\n"); serial_set_baudrate(ROMLOAD_INIT_BAUDRATE); dnload.romload_state = WAITING_IDENTIFICATION; - bsc_schedule_timer(&tick_timer, 0, BEACON_INTERVAL); + bsc_schedule_timer(&tick_timer, 0, dnload.beacon_interval); } break; default: @@ -1244,6 +1245,7 @@ static int parse_mode(const char *arg) "\t\t [ -l /tmp/osmocom_loader ]\n" \ "\t\t [ -m {c123,c123xor,c140,c140xor,c155,romload,mtk} ]\n" \ "\t\t [ -c /to-be-chainloaded-file.bin ]\n" \ + "\t\t [ -i beacon-interval (mS) ]\n" \ "\t\t file.bin\n\n" \ "* Open serial port /dev/ttyXXXX (connected to your phone)\n" \ "* Perform handshaking with the ramloader in the phone\n" \ @@ -1452,8 +1454,9 @@ int main(int argc, char **argv)
dnload.mode = MODE_C123; dnload.chainload_filename = NULL; + dnload.beacon_interval = DEFAULT_BEACON_INTERVAL;
- while ((opt = getopt(argc, argv, "d:hl:p:m:c:s:v")) != -1) { + while ((opt = getopt(argc, argv, "d:hl:p:m:c:s:i:v")) != -1) { switch (opt) { case 'p': serial_dev = optarg; @@ -1478,6 +1481,9 @@ int main(int argc, char **argv) case 'c': dnload.chainload_filename = optarg; break; + case 'i': + dnload.beacon_interval = atoi(optarg) * 1000; + break; case 'h': default: usage(argv[0]); @@ -1530,14 +1536,14 @@ int main(int argc, char **argv) serial_set_baudrate(ROMLOAD_INIT_BAUDRATE); tick_timer.cb = &beacon_timer_cb; tick_timer.data = &tick_timer; - bsc_schedule_timer(&tick_timer, 0, BEACON_INTERVAL); + bsc_schedule_timer(&tick_timer, 0, dnload.beacon_interval); } else if (dnload.mode == MODE_MTK) { tmp_load_address = MTK_ADDRESS; serial_set_baudrate(MTK_INIT_BAUDRATE); tick_timer.cb = &mtk_timer_cb; tick_timer.data = &tick_timer; - bsc_schedule_timer(&tick_timer, 0, BEACON_INTERVAL); + bsc_schedule_timer(&tick_timer, 0, dnload.beacon_interval); }
dnload.load_address[0] = (tmp_load_address >> 24) & 0xff;
Store old_lcr only when switching to LCR == 0xBF. We don't want to clobber old_lcr when switching back, otherwise we can't restore the previous LCR value.
Signed-off-by: Alex Badea vamposdecampos@gmail.com --- src/target/firmware/calypso/uart.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/target/firmware/calypso/uart.c b/src/target/firmware/calypso/uart.c index a46fff9..4d7df09 100644 --- a/src/target/firmware/calypso/uart.c +++ b/src/target/firmware/calypso/uart.c @@ -127,12 +127,12 @@ static void uart_set_lcr7bit(int uart, int on) static uint8_t old_lcr; static void uart_set_lcr_bf(int uart, int on) { - old_lcr = readb(UART_REG(uart, LCR)); - - if (on) + if (on) { + old_lcr = readb(UART_REG(uart, LCR)); writeb(0xBF, UART_REG(uart, LCR)); - else + } else { writeb(old_lcr, UART_REG(uart, LCR)); + } }
/* Enable or disable the TCR_TLR latch bit in MCR[6] */
Don't assign to the variable given as argument. This prevents clobbering the local 'reg' variables in uart_reg_{read,write}(), which would in turn prevent the latch bits from being restored correctly.
Signed-off-by: Alex Badea vamposdecampos@gmail.com --- src/target/firmware/calypso/uart.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/target/firmware/calypso/uart.c b/src/target/firmware/calypso/uart.c index 4d7df09..394078d 100644 --- a/src/target/firmware/calypso/uart.c +++ b/src/target/firmware/calypso/uart.c @@ -43,7 +43,7 @@ #define LCR7BIT 0x80 #define LCRBFBIT 0x40 #define MCR6BIT 0x20 -#define REG_OFFS(m) ((m) &= ~(LCR7BIT|LCRBFBIT|MCR6BIT)) +#define REG_OFFS(m) ((m) & ~(LCR7BIT|LCRBFBIT|MCR6BIT)) /* read access LCR[7] = 0 */ enum uart_reg { RHR = 0,
Append $(HOST_CONFARGS) to ./configure scripts for 'host' applications.
This allows e.g. cross-compiling on an x86 build system for an OpenMoko gta0x host, using an invocation such as:
$ make HOST_CONFARGS="--host=arm-angstrom-linux-gnueabi"
Signed-off-by: Alex Badea vamposdecampos@gmail.com --- src/Makefile | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Makefile b/src/Makefile index c8caff0..1567d2d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,7 +23,7 @@ shared/libosmocore/configure: shared/libosmocore/configure.in cd shared/libosmocore && autoreconf -i
shared/libosmocore/build-host/Makefile: shared/libosmocore/configure shared/libosmocore/build-host - cd shared/libosmocore/build-host && ../configure + cd shared/libosmocore/build-host && ../configure $(HOST_CONFARGS)
shared/libosmocore/build-host/src/.libs/libosmocore.la: shared/libosmocore/build-host/Makefile cd shared/libosmocore/build-host && make @@ -51,7 +51,7 @@ host/osmocon/configure: host/osmocon/configure.ac cd host/osmocon && autoreconf -i
host/osmocon/Makefile: host/osmocon/configure - cd host/osmocon && $(OSMOCORE_CONFIGURE_ENV) ./configure + cd host/osmocon && $(OSMOCORE_CONFIGURE_ENV) ./configure $(HOST_CONFARGS)
host/osmocon/osmocon: host/osmocon/Makefile libosmocore-host make -C host/osmocon @@ -64,7 +64,7 @@ host/gsmmap/configure: host/gsmmap/configure.ac cd host/gsmmap && autoreconf -i
host/gsmmap/Makefile: host/gsmmap/configure - cd host/gsmmap && $(OSMOCORE_CONFIGURE_ENV) ./configure + cd host/gsmmap && $(OSMOCORE_CONFIGURE_ENV) ./configure $(HOST_CONFARGS)
host/gsmmap/gsmmap: host/gsmmap/Makefile libosmocore-host make -C host/gsmmap @@ -77,7 +77,7 @@ host/layer23/configure: host/layer23/configure.ac cd host/layer23 && autoreconf -i
host/layer23/Makefile: host/layer23/configure - cd host/layer23 && $(OSMOCORE_CONFIGURE_ENV) ./configure + cd host/layer23 && $(OSMOCORE_CONFIGURE_ENV) ./configure $(HOST_CONFARGS)
host/layer23/layer23: host/layer23/Makefile libosmocore-host make -C host/layer23
Hi Alex!
Thanks a lot for your bugfixes and updates. Your work on the Openmoko phones is definitely appreciated. I've applied all patches to the repo.
baseband-devel@lists.osmocom.org