ChibiOS “undefined reference to `_sbrk'” linker error

If we get this linker error with ChibiOS:

/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status

we simply need to add syscalls.c to be compiled, add the following to CSRC in the Makefile:

$(CHIBIOS)/os/various/syscalls.c

We should underline that _sbrk will work correctly if and only if CH_CFG_USE_MEMCORE == TRUE (editable in chconf.h). Else, malloc() will always return 0 and result in an errno of ENOMEM.

Find machine/host names on the network

Firstly we try to resolve the PTR records in DNS for the specified IP addresses.
It sends nothing to the hosts so there is no guarantee if it is really connected or turned on but we can get the actual DNS map including those devices which are within their DHCP lease timeout.

nmap -sn -sL 192.168.0.0/24

Then we scan for hosts really connected sending ARP requests. The disadvantage is that it only works on your subnet.

nmap -sP 192.168.0.0/24

or if we want to remove useless lines:

nmap -sP 192.168.0.0/24 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}"

output example:

cesare@cesare-desktop:~$ nmap -sP 192.168.0.0/24 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}"
 Nmap scan report for router (192.168.0.10)
 Nmap scan report for vpnudp (192.168.0.90)
 Nmap scan report for vpntcp (192.168.0.91)
 Nmap scan report for desktop (192.168.0.100)
 Nmap scan report for unas (192.168.0.110)
 Nmap scan report for pi2 (192.168.0.140)
 Nmap scan report for cloud (192.168.0.200)

or for a better output:

nmap -sP 192.168.0.0/24 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d ' ' -f5-
router (192.168.0.10)
vpnudp (192.168.0.90)
vpntcp (192.168.0.91)
desktop (192.168.0.100)
unas (192.168.0.110)
cloud (192.168.0.200)

How to install the Virtualbox SDK

Download and extract the SDK package. The target directory will be sdk.

If we try to execute directly the installer we will get:

python sdk/installer/vboxapisetup.py install
Traceback (most recent call last):
  File "sdk/installer/vboxapisetup.py", line 88, in <module>
    main(sys.argv)
  File "sdk/installer/vboxapisetup.py", line 61, in main
    raise Exception("No VBOX_INSTALL_PATH defined, exiting")
Exception: No VBOX_INSTALL_PATH defined, exiting

To install correctly we have to launch locally the install script.

cd sdk/installer
export VBOX_INSTALL_PATH=$(which virtualbox)
sudo -E python vboxapisetup.py install

ASUS WL-500GP v2: flash firmware using CFE

I had a bricked router Asus WL500GP v2, luckily the CFE bootloader was still reachable through serial port. After setup a TFTP server and downloaded the appropriate upgraded firmware from OpenWrt, the CFE command was:

flash -noheader 192.168.1.100:openwrt.trx flash1.trx

where:

  • flash1.trx is the destination flash (and not flash0.trx as I saw in some tutorials)
  • 192.168.1.100 is the TFTP server IP
  • openwrt.trx is the firmware image
  • -no header is that option to override header verification

WordPress Themes