Commit Graph

88 Commits

Author SHA1 Message Date
Harald Welte 855cea6318 osmoload: Use osmo_sock_unix_init_ofd() from libosmocore
We don't need to hand-code unix domain socket initialization but
can simply use our library function for it.  As an added benefit,
the library code already contains corner case handling for non-NUL
terminated unix domain socket path.

Change-Id: Iedcec4591cf0fcbd6f956ed022169eae10a9b16e
2018-09-06 16:14:47 +02:00
Harald Welte db144ce571 osmocon: Use osmo_sock_unix_init_ofd() from libosmocore
We don't need to hand-code unix domain socket initialization but
can simply use our library function for it.  As an added benefit,
the library code already contains corner case handling for non-NUL
terminated unix domain socket path.

Change-Id: I3ab69a971be555c9f9b5b7a7e5da53008a119504
2018-09-06 16:14:44 +02:00
Harald Welte 114fbda5d4 osmocon: Add --enable-{werror,sanitize} configure flags
Change-Id: I6a69ca514406fa18684ca2621be45f87ee8d64a4
2018-09-06 15:03:07 +02:00
Stefan Sperling 9d6d9a6b3b osmocon: fix read buffer overrun in romload_prepare_block()
Address sanitizer triggered when trying to chainload firmware:

==18466==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x631000027850 at pc 0x7f5b94cfb733 bp 0x7ffe33e1ae30 sp 0x7ffe33e1a5d8
READ of size 1014 at 0x631000027850 thread T0
    #0 0x7f5b94cfb732  (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x79732)
    #1 0x563db4293e6e in memcpy /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
    #2 0x563db4293e6e in romload_prepare_block osmocom-bb/src/host/osmocon/osmocon.c:473
    #3 0x563db429541f in handle_read_romload osmocom-bb/src/host/osmocon/osmocon.c:959
    #4 0x563db429541f in serial_read osmocom-bb/src/host/osmocon/osmocon.c:1168
    #5 0x7f5b94722c83 in osmo_fd_disp_fds libosmocore/src/select.c:217
    #6 0x7f5b94722f84 in osmo_select_main libosmocore/src/select.c:257
    #7 0x563db4293b1c in main osmocom-bb/src/host/osmocon/osmocon.c:1525
    #8 0x7f5b942b9b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #9 0x563db4293c79 in _start (prefix/sbin/osmocon+0x1c79)

0x631000027850 is located 0 bytes to the right of 77904-byte region [0x631000014800,0x631000027850)
allocated by thread T0 here:
    #0 0x7f5b94d60b50 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb50)
    #1 0x563db4294d65 in read_file osmocom-bb/src/host/osmocon/osmocon.c:314

Change-Id: Ie2955e11dd1af75574536774ef7ddf88ddf1fe8b
2018-08-24 10:28:19 +00:00
Stefan Sperling 677a0f8142 osmocon: fix use of an initialized variable
osmocon.c: In function ‘read_file’:
osmocon.c:317:3: warning: ‘fd’ may be used uninitialized in this function

Change-Id: If07c58d5b55c18c05345607064eace02748935f8
2018-08-23 14:52:56 +02:00
Pau Espin ac37f55b1c osmoload: Set compiler attr to unused function
Function is not removed as documentation of the load process
capabilities.

Change-Id: I8e838cbb5ae7c9a2f4d0e249fc14f7cbcbc2cb07
2018-06-13 13:48:17 +02:00
Pau Espin f5481937a7 osmocon: Set compiler attr to unused variables
Variables are not removed as they document the commands of the
propietary romloader.

Let's mark them as unused to avoid compilation warnings.

Change-Id: If4c6814ada85956975e687eb43dcfd4ad70b8b94
2018-06-13 13:42:52 +02:00
Pau Espin 40d9d853e8 osmocon: Fix printf format
Fixes compilation warning:
osmocon.c:650:21: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long int’ [-Wformat=]
  printf("%u bytes (%u/%u)\n", rc, dnload.write_ptr - dnload.data,
                    ~^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    %lu

Change-Id: I1e9e10e756d8a612425ee71f4ac0139b2293d3bb
2018-06-12 17:10:14 +02:00
Pau Espin 9941ebd519 osmoload: Remove duplicate const keyword
Fixes compilation warning:
warning: duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier]
  const uint8_t const *endptr = bufptr + len;
                ^~~~~

Change-Id: Ibafa439c9d7f7aab6d417eca5ff045766ac27b4f
2018-06-12 16:59:44 +02:00
Pau Espin 5c576686e2 osmocon: Call osmo_init_ignore_signals at startup
It disables undesirable signals such as SIGPIPE, which exits the program
if the client connected to osmocon closes the connection and osmocon
writes to the connection fd. After SIGPIPE is disabled, write returns
-EPIPE.

This is required to keep osmocon running for BTS_Tests.ttcn TTCN3 tests.

Change-Id: Id664ca0fadd3a8b3cf4b78bb868b3d78d2354544
2018-06-12 16:54:10 +02:00
Pau Espin 9533aa7002 osmocon: Makefile.am: Fix build using different path
Change-Id: I1a322e364612976f3d797f25e57ccc7c2354bd5e
2018-05-22 16:04:06 +02:00
Vadim Yanitskiy f978a66ca6 osmocon.c: strip unused variable
Change-Id: I295785295c108798e0c235e78bd8fd8f3c585d16
2017-05-24 22:22:33 +00:00
Andreas Eversberg 8a8796802b osmocon: Improve performance by handling several serial bytes at a time 2013-06-19 15:16:58 +02:00
Bhaskar c6cab89f76 host/osmocon: fix some printf format specifier in handle_write_dnload
From: Bhaskar <niceguy108@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-05-23 08:25:18 +02:00
Bhaskar 78bcbd6cdb osmoload: Fix fall-out from msgb_get() / msgb_pull() transition
Bugfix in Osmoload.c: Assigning correct value to data pointer in
LOADER_MEM_READ. Wrong value was introduced in last update when
msgb_get() was replaced by msgb_pull() which returns end of data instead
of start of data.
2013-05-23 07:44:50 +02:00
Steve Markgraf 1479b6812b osmocon: embed chainloader
This allows to directly load highram-images on
compal phones with the commandline-switch
-c.

Signed-off-by: Steve Markgraf <steve@steve-m.de>
2013-04-07 11:34:48 +02:00
Steve Markgraf 9fc6377003 osmocon: make romloader output much less verbose
Most of the output was only for debug purposes anyway.

Signed-off-by: Steve Markgraf <steve@steve-m.de>
2013-01-05 18:37:12 +01:00
Harald Welte 6ce46e7a86 use msgb_pull() to get bytes from start of message, not msgb_get()
msgb_get() is for getting bytes from the end of a message, but it
was broken in libosmocore for a long time (until it was fixed today).
2012-09-08 22:45:30 +02:00
Steve Markgraf 90ab06ce5c host/osmocon: allow uploading of files > 64kb in romload-mode
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2012-02-08 21:43:29 +01:00
Alexander Huemer 9bfb7d42b3 host/osmocon: correct parsing of -m
Written-by: Alexander Huemer <alexander.huemer@xx.vu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-12-14 20:32:17 +01:00
Holger Hans Peter Freyther a73c98a3ab osmocom: Address warning about aliasing
We alias the uint8_t buf[..] to a uint16_t* which is violating
the aliases rule of C. Use an explicit memcpy to copy the first
two byte of the buffer. GCC 4.6.2 (debian) is clever enough to
use a normal load does not generate a memcpy call.

osmocon.c: In function ‘un_tool_read’:
osmocon.c:1239:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
2011-11-06 22:10:42 +01:00
Holger Hans Peter Freyther 6d1f116338 misc: u_intX -> uintX in the host directory
Use C99 stdint.h for the inttypes.
2011-11-06 21:55:40 +01:00
Steve Markgraf 7bbd2ac411 host/osmocon: make auto-reload/reboot feature work in chainloading-mode
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2011-09-05 02:41:41 +02:00
Sylvain Munaut 01e64fceb2 host/osmocon: Make use of the libosmcore serial helpers
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-09-02 22:36:38 +02:00
Harald Welte b631c289c3 osmocon: if we ignore a return value, we don't need to assign it to a variable 2011-07-16 17:34:07 +02:00
Harald Welte 1520fad932 osmocon: get rid of some Smash warnings 2011-07-16 14:52:18 +02:00
Pablo Neira Ayuso 63cca6660f src: use namespace prefix osmo_* for crc16 functions
Summary of changes:

s/crc16_table/osmo_crc16_table/g
s/crc16/osmo_crc16/g
s/crc16_byte/osmo_crc16_byte/g
2011-05-15 17:33:28 +02:00
Pablo Neira Ayuso a1d1680245 src: use namespace prefix osmo_* for utils
Summary of changes:

s/bcd2char/osmo_bcd2char/g
s/char2bcd/osmo_char2bcd/g
s/hexparse/osmo_hexparse/g
s/hexdump/osmo_hexdump/g
s/hexdump_nospc/osmo_hexdump_nospc/g
s/ubit_dump/osmo_ubit_dump/g
s/static_assert/osmo_static_assert/g
2011-05-15 17:33:26 +02:00
Pablo Neira Ayuso ffcc29b5fb src: use namespace prefix osmo_fd* and osmo_select*
Summary of changes:

s/struct bsc_fd/struct osmo_fd/g
s/bsc_register_fd/osmo_fd_register/g
s/bsc_unregister_fd/osmo_fd_unregister/g
s/bsc_select_main/osmo_select_main/g
2011-05-15 14:39:33 +02:00
Pablo Neira Ayuso d3ba2f6037 src: use namespace prefix osmo_timer*
Summary of changes:

s/struct timer_list/struct osmo_timer_list/g
s/bsc_add_timer/osmo_timer_add/g
s/bsc_schedule_timer/osmo_timer_schedule/g
s/bsc_del_timer/osmo_timer_del/g
s/bsc_timer_pending/osmo_timer_pending/g
s/bsc_nearest_timer/osmo_timers_nearest/g
s/bsc_prepare_timers/osmo_timers_prepare/g
s/bsc_update_timers/osmo_timers_update/g
s/bsc_timer_check/osmo_timers_check/g
2011-05-15 14:39:30 +02:00
Pablo Neira Ayuso ade79a0083 src: use new libosmogsm and include/osmocom/[gsm|core] path to headers
This patch changes include paths to get osmocom-bb working with
the current libosmocore tree.

Among all these renames, you can notice several tweaks that I
added on purpose, and that require some explanation, they are:

* hexdump() in osmocon.c and osmoload.c has been renamed to avoid
clashing with hexdump() defined in libosmocore.

* gsmmap now depends on libosmogsm. Actually I had to cleanup
Makefile.am because I was experiencing weird linking problems,
probably due to a bug in the autotools. With the change included
in this patch, I got it compiled and linked here correctly.

This patch has been tested with the phone Motorola C123 and the
following images files:

* firmware/board/compal_e88/hello_world.compalram.bin
* firmware/board/compal_e88/layer1.compalram.bin

Using the osmocon, bcch_scan and mobile tools.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-04-26 02:55:30 +02:00
Alex Badea a69d67ec73 osmocon: make beacon interval configurable via cmdline
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>
2010-11-17 23:39:45 +01:00
Holger Hans Peter Freyther bc1e9354f7 osmoload.c: Cast to uint8_t from char* to fix a compiler warning 2010-10-03 02:29:58 +08:00
Holger Hans Peter Freyther ef365cc9ad osmocom.c: rc is not assigned and contains garbage, return 0. 2010-10-03 02:20:32 +08:00
Holger Hans Peter Freyther ef9298d915 osmocon.c: Use C99 inttypes instead of u_intX_t. 2010-10-03 02:16:32 +08:00
Sylvain Munaut 76f9a67fa7 misc: update .gitignore files
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-09-14 21:21:42 +02:00
Steve Markgraf c80988f4b9 [osmocon] add a chainloading mode for the compal ramloader
The idea is to load a small application to the phone, which
activates and executes the Calypso romloader. The payload
itself then is loaded with the romloader, bypassing the magic
and the resulting size limit on the C139/C140 and J100i.

Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-07-20 14:41:21 +02:00
Ingo Albrecht bc65d6905d loader: meaner. now supports address ranges for all relevant flash operations. reports better. 2010-07-20 14:41:21 +02:00
Ingo Albrecht e7afe1df98 osmoload: better message 2010-07-20 14:41:20 +02:00
Ingo Albrecht 11949dd907 osmocon: new debug option, allows selective dumping of rx and/or tx. 2010-07-20 14:41:20 +02:00
Ingo Albrecht 605b9ea5e6 osmoload: fixed programming abort 2010-07-20 14:41:20 +02:00
Ingo Albrecht 0412184b8d osmoload: flash programming 2010-07-20 14:41:20 +02:00
Ingo Albrecht e4ad7b6827 osmoload: allow running without firmware image 2010-07-20 14:41:19 +02:00
Ingo Albrecht 3936c397a7 loader: flash locking commands, various flash rework 2010-07-20 14:41:19 +02:00
Ingo Albrecht cb2cdd0221 loader: new state handling for memdump, added missing crc handling to memput 2010-07-20 14:41:19 +02:00
Ingo Albrecht f0f2dc81ee loader: incomplete crc support and query timeouts 2010-07-20 14:41:19 +02:00
Ingo Albrecht 23017a5fd4 osmoload: fix some printfs. 2010-07-20 14:41:19 +02:00
Ingo Albrecht 42984320de loader: reply dump mode. additional information in init reply. 2010-07-20 14:41:19 +02:00
Ingo Albrecht 0a5a737419 osmoload: command reorg, state machine reorg, query timeouts 2010-07-20 14:41:19 +02:00
Ingo Albrecht 311847997f osmoload: Added a jump command. 2010-07-20 14:41:19 +02:00