summaryrefslogtreecommitdiffstats
path: root/src/host/osmocon/osmocon.c
AgeCommit message (Collapse)AuthorFilesLines
2019-07-21osmocon: Check write() return codeHarald Welte1-0/+2
Change-Id: I61d8f104a4d2558fd5b6fb34c7f2fd6c13354c12 Closes: CID#198567
2019-07-21osmocon: Add missing check for fstat() return valueHarald Welte1-0/+5
Change-Id: Ibef6ee00eb41e16d2ef52931f8c22562090cd1ee Closes: CID#198570
2019-07-21osmocon: Fix file descriptor + mem leak in error pathHarald Welte1-0/+3
Change-Id: I42ceed662889084783dc89f4ca39c3852428d108 Closes: CID#198539
2019-07-21osmocon: Fix fd leak in error path of read_file()Harald Welte1-0/+1
Change-Id: Iaae407658df184277f6e6e07d6a48d8b5c75587b Closes: CID#198552
2019-07-21osmocon: Fix out-of-bounds for partial reads in un_tool_read()Harald Welte1-2/+2
"uint8_t buf[4096]; ... &buf + 1" renders an offset of 4096, and not 1! Change-Id: Ie1407371fe949c3d5746b9fdc32ececc9443692b Closes: CID#198580
2018-09-06osmocon: Use osmo_sock_unix_init_ofd() from libosmocoreHarald Welte1-41/+4
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-08-24osmocon: fix read buffer overrun in romload_prepare_block()Stefan Sperling1-1/+1
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-23osmocon: fix use of an initialized variableStefan Sperling1-1/+2
osmocon.c: In function ‘read_file’: osmocon.c:317:3: warning: ‘fd’ may be used uninitialized in this function Change-Id: If07c58d5b55c18c05345607064eace02748935f8
2018-06-13osmocon: Set compiler attr to unused variablesPau Espin Pedrol1-2/+2
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-12osmocon: Fix printf formatPau Espin Pedrol1-1/+1
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-12osmocon: Call osmo_init_ignore_signals at startupPau Espin Pedrol1-0/+3
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
2017-05-24osmocon.c: strip unused variableVadim Yanitskiy1-3/+2
Change-Id: I295785295c108798e0c235e78bd8fd8f3c585d16
2013-06-19osmocon: Improve performance by handling several serial bytes at a timeAndreas Eversberg1-8/+19
2013-05-23host/osmocon: fix some printf format specifier in handle_write_dnloadBhaskar1-1/+1
From: Bhaskar <niceguy108@gmail.com> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-04-07osmocon: embed chainloaderSteve Markgraf1-44/+65
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-01-05osmocon: make romloader output much less verboseSteve Markgraf1-20/+5
Most of the output was only for debug purposes anyway. Signed-off-by: Steve Markgraf <steve@steve-m.de>
2012-02-08host/osmocon: allow uploading of files > 64kb in romload-modeSteve Markgraf1-1/+1
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2011-12-14host/osmocon: correct parsing of -mAlexander Huemer1-2/+3
Written-by: Alexander Huemer <alexander.huemer@xx.vu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-06osmocom: Address warning about aliasingHolger Hans Peter Freyther1-1/+2
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-09-05host/osmocon: make auto-reload/reboot feature work in chainloading-modeSteve Markgraf1-2/+17
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2011-09-02host/osmocon: Make use of the libosmcore serial helpersSylvain Munaut1-72/+10
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-07-16osmocon: if we ignore a return value, we don't need to assign it to a variableHarald Welte1-3/+1
2011-07-16osmocon: get rid of some Smash warningsHarald Welte1-6/+6
2011-05-15src: use namespace prefix osmo_* for utilsPablo Neira Ayuso1-4/+4
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-15src: use namespace prefix osmo_fd* and osmo_select*Pablo Neira Ayuso1-12/+12
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-15src: use namespace prefix osmo_timer*Pablo Neira Ayuso1-9/+9
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-04-26src: use new libosmogsm and include/osmocom/[gsm|core] path to headersPablo Neira Ayuso1-8/+8
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>
2010-11-17osmocon: make beacon interval configurable via cmdlineAlex Badea1-10/+16
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-10-03osmocom.c: rc is not assigned and contains garbage, return 0.Holger Hans Peter Freyther1-2/+2
2010-10-03osmocon.c: Use C99 inttypes instead of u_intX_t.Holger Hans Peter Freyther1-5/+5
2010-07-20[osmocon] add a chainloading mode for the compal ramloaderSteve Markgraf1-6/+27
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-20osmocon: new debug option, allows selective dumping of rx and/or tx.Ingo Albrecht1-24/+49
2010-07-20osmoload: allow running without firmware imageIngo Albrecht1-12/+13
2010-07-15osmocon.c: enable hdlc console for mtk romloader targetsSteve Markgraf1-5/+5
Since the mt622x uart driver is now in a working state, we can actually use the sercomm console. Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-05-19osmocon: extend hexdump to show all printable charactersJan Luebbe1-3/+9
2010-05-19osmocon: change mtk load address for MT6223 romloaderSteve Markgraf1-1/+1
The romloader of the MT6223 uses more of the internal SRAM than the loader of the MT6227, thus we need to change the load address. Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-05-17osmocon: Add experimental support for the MTK romloaderSteve Markgraf1-10/+291
Currently the switch to a higher baudrate is missing, which has to be done by a direct UART autobaud register write, plus sending an autobaud sample. As a result, the maximum download speed is currently 19.200 Baud. Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-05-17osmocon: use a global load addressSteve Markgraf1-9/+11
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-05-17osmocon: cosmetic cleanupSteve Markgraf1-19/+22
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-05-17osmocon: use osmocore timers, minor fixesSteve Markgraf1-42/+15
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-05-17osmocon.c: Fix serial_set_baudrate functionDaniel Willmann1-0/+5
We have to call tcgetattr prior to changing the baudrate and writing the struct again.
2010-04-21osmocom: Fix serial init (CSIZE field)Sylvain Munaut1-1/+1
Since we clear the whole CSIZE, we need to set CS8 _after_ the clearing or it'll just get erased ... Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-04-07osmocon: fix c140xor, fix compiler warnings due to unhandled cases, cleanupSteve Markgraf1-15/+20
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-04-06osmocon: use git-version-gen and PACKAGE_VERSION for 'osmocon -v'Harald Welte1-3/+1
2010-04-06osmocon: cosmetic cleanup (mostly 80character line length)osmocon_v0.0.0Harald Welte1-80/+128
2010-04-06osmocon: * introduce support for "non-secure" romloader inside ↵Steve Markgraf1-31/+464
Calypso/Calypso lite, "-m romload", tested on the BenQ Siemens A38 * automatically add the required 1003 magic for the C139, C140 and J100i "-m c140/c140xor", intended for loading loader.ramload.bin, and loading the application itself with "osmoload memload" on these targets * replace null-terminated string "ftmtool" with uint8_t (length was 8, so the ftmtool message was only recognized when the byte following to our allocated buffer memory was 0x00) * fix minor compiler warnings * add copyright message Signed-off-by: Steve Markgraf <steve@steve-m.de>
2010-03-30osmocon: use serial port initialization code from openbsc/src/rs232.cHarald Welte1-43/+38
Both have the same goal: put the RS232 port into a completely raw, binary-transparent mode. So there's no point in keeping two completely different functions for this.
2010-03-30osmocon: calcluate unix domain socket length in a portable wayHarald Welte1-2/+15
Let's hope this concept (as seen in Xorg sources) is portable enough to calculate the length of the sockaddr_un properly on all architectures.
2010-03-22misc compiler warning fixesHarald Welte1-3/+3
* added missing param in call to gsm48_rx_bcch * added 'extern' to declarations of rsl_rlm_cause_strs and target_board * added several 'const' for strings * removed useless 'bufptr,' from hexdump (From: itsme <itsme@xs4all.nl>)
2010-03-19Two more small patchesErik Ekman1-2/+2
Hi Found a spelling error while testing my C139, and also fixed the warning discussed in my earlier patch. /Erik From 9d8a7454367f3d095e6d4c046e84a22126ff887a Mon Sep 17 00:00:00 2001 From: Erik Ekman <yarrick@kryo.se> Date: Wed, 17 Mar 2010 22:48:57 +0100 Subject: [PATCH 1/2] Remove operand which has no effect Signed-off-by: Ingo Albrecht <prom@berlin.ccc.de>