It’s not always easy to read the part number on IC you find on boards, and some time ago, I watched a video where Lady Ada used a USB microscope to demonstrate how to solder some components, and probably using that 5.0 MP model sold on Adafruit for about $80. But I found a similar looking USB microscope with a 2.0MP sensor and 1000X magnification on Ebay for $16.59 shipped, so I bought it, received it today, and I’ve given it a try. Such microscopes can be used to inspect skin and hair, PCB, textile, bank notes, jewelery, and so on. There are apparently other models based on the one I purchased with useful features like auto-focus, wireless support, different levels of magnification, and different colors. Supported operating systems include Windows and Linux, Android, and Windows 8 according to the package. The microscope comes with a stand, a CDROM with […]
GNU Complexity Command Line Tool Measures Complexity of C Code
GNU complexity is a command line tool that computes a complexity measure of C source code, similar to pmccabe, but with a different method of calculating results with short functions scoring lower than pmccabe and highly nested functionality can score considerably higher. It can be useful to locate suspicious areas in unfamiliar code, get an idea of the efforts required to either understand the code or test it, or self-assess your own code. Bruce Korb, the maintainer, has just released version 1.5 with some bug fixes, so I’ve given it a quick try. We’ll need to get the code, build and install it first:
|
1 2 3 4 5 6 |
wget ftp://ftp.gnu.org/gnu/complexity/complexity-1.5.tar.gz tar xvf complexity-1.5.tar.gz cd complexity-1.5 ./configure make -j8 sudo make install |
The user’s manual provides some insights and an example, which I’ve used against a directory in Linux source code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
cd ~/edev/linux/arch/arm64/kernel complexity --histogram --score --thresh=3 `ls *.c` procedure fpsimd_pm_init in fpsimd.c ended before final close bracket procedure fpsimd_hotplug_init in fpsimd.c ended before final close bracket Complexity Scores Score | ln-ct | nc-lns| file-name(line): proc-name 3 28 17 perf_callchain.c(111): perf_callchain_user 3 20 18 insn.c(337): aarch64_insn_decode_immediate 3 21 19 io.c(27): __memcpy_fromio 3 21 19 io.c(56): __memcpy_toio 3 30 19 cpufeature.c(860): verify_local_cpu_capabilities 3 21 20 module.c(74): reloc_data 3 24 20 setup.c(199): request_standard_resources 3 27 20 alternative.c(89): __apply_alternatives 3 29 20 cpu_ops.c(53): cpu_read_enable_method 3 29 24 insn.c(362): aarch64_insn_encode_immediate 3 31 24 ptrace.c(76): ptrace_hbptriggered 3 54 24 kgdb.c(159): kgdb_arch_handle_exception 3 28 25 armv8_deprecated.c(145): update_insn_emulation_mode 3 32 25 debug-monitors.c(334): aarch32_break_handler 3 35 26 smp.c(413): acpi_map_gic_cpu_interface 3 42 26 process.c(249): copy_thread 3 58 27 perf_event.c(572): armv8pmu_handle_irq 3 32 28 hw_breakpoint.c(544): toggle_bp_registers 3 34 28 insn.c(1019): aarch64_insn_gen_data3 3 34 29 insn.c(519): aarch64_insn_gen_comp_branch_imm 3 56 29 setup.c(121): smp_build_mpidr_hash 3 35 30 insn.c(397): aarch64_insn_encode_register 3 42 31 signal.c(167): setup_sigframe 3 37 33 hw_breakpoint.c(349): arch_bp_generic_fields 3 49 34 setup.c(232): relocate_initrd 3 41 35 insn.c(708): aarch64_insn_gen_add_sub_imm 3 63 38 setup.c(292): setup_arch 3 109 57 cpufeature.c(469): update_cpu_features 4 46 26 smp.c(477): of_parse_and_init_cpus 4 38 31 traps.c(335): call_undef_hook 4 36 32 insn.c(924): aarch64_insn_gen_data1 4 49 33 armv8_deprecated.c(464): cp15barrier_handler 4 71 34 stacktrace.c(41): unwind_frame 4 42 35 ptrace.c(437): hw_break_set 4 42 37 insn.c(968): aarch64_insn_gen_data2 4 49 37 smp.c(708): handle_IPI 4 58 37 hw_breakpoint.c(231): hw_breakpoint_control 4 47 40 insn.c(757): aarch64_insn_gen_bitfield 4 54 44 ptrace.c(376): hw_break_get 4 60 44 armv8_deprecated.c(378): swp_handler 5 28 27 hw_breakpoint.c(198): hw_breakpoint_slot_setup 5 45 35 ptrace.c(672): compat_gpr_get 5 50 36 hw_breakpoint.c(764): reinstall_suspended_bps 5 59 37 hw_breakpoint.c(476): arch_validate_hwbkpt_settings 5 48 42 insn.c(811): aarch64_insn_gen_movewide 5 49 42 insn.c(868): aarch64_insn_gen_add_sub_shifted_reg 5 60 44 psci.c(36): cpu_psci_cpu_init_idle 5 49 46 insn.c(277): aarch64_get_imm_shift_mask 5 95 89 asm-offsets.c(34): main 6 34 32 cpufeature.c(792): __raw_read_system_reg 6 67 37 signal.c(332): do_signal 6 43 39 topology.c(50): parse_core 6 54 41 ptrace.c(724): compat_gpr_set 6 74 44 traps.c(147): dump_backtrace 6 55 49 insn.c(646): aarch64_insn_gen_load_store_pair 6 76 49 hw_breakpoint.c(393): arch_build_bp_info 6 71 52 hw_breakpoint.c(584): breakpoint_handler 6 61 54 insn.c(1062): aarch64_insn_gen_logical_shifted_reg 6 73 59 ptrace.c(1120): compat_arch_ptrace 8 50 30 cpuinfo.c(102): c_show 8 64 50 topology.c(97): parse_cluster 8 97 65 hw_breakpoint.c(660): watchpoint_handler 9 44 32 traps.c(59): dump_mem 11 71 55 signal32.c(129): copy_siginfo_to_user32 31 198 172 module.c(184): apply_relocate_add Complexity Histogram Score-Range Lin-Ct 0-9 2206 ************************************************************ 10-19 55 * 20-29 0 30-39 172 ***** Scored procedure ct: 65 Non-comment line ct: 2433 Average line score: 7 25%-ile score: 3 (75% in higher score procs) 50%-ile score: 5 (half in higher score procs) 75%-ile score: 6 (25% in higher score procs) Highest score: 31 (apply_relocate_add() in module.c) |
The resulting table shows six information per line: the computed score, the number of lines between the opening and closing curly braces (ln-ct), the number […]
Hexiwear is an Open Source Wearable Development Kit Expandable with Add-on Boards (Crowdfunding)
MikroElektronika has designed Hexiwear, a wearable development kit that you can wear and hack as a smartwatch thanks to an (optionally) included wristband, or use a an IoT development kit thanks to its docking station taking up to three “Click” boards among a choice of over 180 modules. . Hexiwear hardware specifications: MCU – NXP Kinetis K64x ARM Cortex-M4 MCU @ 120 MHz with 1MB Flash and 256KB SRAM Storage – 8 MB Flash memory Display – 1.1” full color OLED display with capacitive touch Connectivity – Bluetooth 4.0 LE and 802.15.4 via NXP Kinetis KW4x Cortex-M0+ wireless MCU Sensors -3D accelerometer and magnetometer (NXP FXOS8700CQ), 3-Axis gyroscope (NXP FXAS21002), pressure sensor (NXP MPL3115A2R1), light-to-digital converter, humidity and temperature sensor, heart-rate sensor (HRM) USB – micro USB cable for power and charging Misc – RGB LED, haptic feedback engine, docking connector Battery – 190 mAh 2C Li-Po battery; 600 mA […]
Microchip Introduces MPLAB Xpress Cloud-based IDE and MPLAB Xpress Evaluation Board
Microchip has just launched MPLAB Xpress online IDE with some of the most used features of the company’s MPLAB X IDE, as well as a free – in limited quantities – MPLAB Xpress evaluation board based on a PIC16 micro-controller. Let’s get through the development board specifications first: MCU – Microchip PIC16F18855 MCU with 14KB flash, 1KB SRAM, 256 bytes EEPROM USB – micro USB port for power and programming Expansion Headers Unpopulated mikroBUS header supporting one of 180 Click boards Unpopulated 2x 14-pin header with GPIOs, I2C, SPI, UART, ADC, etc… Misc – Reset button, user button, potentiometer Dimensions – N/A Playing with hardware is always more fun, but if you just want to evaluation the online IDE, you don’t even need the board. Visit MPLAB Xpress Code Examples page, load one of the example, possibly log-in if you want to save changes to the 10GB free online storage […]
STMicro Releases Linux based STM32 MCU Development Tools
Until a few years ago, most development tools for micro-controllers were only available for Windows, but as Linux gained popularity among developers and engineers, community of developers designed development tools running in Linux, but only a few companies are providing tools that run on Linux operating systems. The good news is that STMicro has just announced the release of STM32CubeMX configurator and System Workbench for STM32, for both Linux and Windows, with Mac OS supporting coming on Q2 2016. Developped by Ac6 embedded systems company, System Workbench for STM32 relies on Eclipse IDE, supports the ST-LINK/V2 debugging tool under Linux through an adapted version of the OpenOCD project, and can be used with various STMicro STM32 boards including Nucleo boards, Discovery kits, and other Evaluation boards. You can give it a try by visiting OpenSTM32 Community, but for some reasons they ask you to register before accessing the installation instructions. […]
How to Resize Android’s Internal Storage Partition in Rockchip Devices
I installed Light Biz OS firmware on GeekBox yesterday, but I’ve quickly realized many applications such as Gimp Inkscape would not install due to the small 1.94GB “internal partition”, so I asked how to increase the partition size in GeekBox forums last evening, and got an answer overnight from “dewet”. The good news is that it worked so I’ll share the steps I followed in a computer running Ubuntu 14.04. It might also be possible to perform the same tasks within a Windows machine with Rorkchip’s Factory tools First let’s download the utils with relevant scripts and binaries:
|
1 2 |
git clone https://github.com/geekboxzone/utils cd utils/rockdev |
Now copy your device or board’s firmware file “update.img” to the working directory, and unpack it:
|
1 |
./unpack.sh update.img |
The output should look like:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
start to unpack update.img... ********RKImageMaker ver 1.61******** Unpacking image, please wait... Exporting boot.bin Exporting firmware.img Unpacking image success. Android Firmware Package Tool v1.0 Check file... OK ------- UNPACK ------ package-file 0x00000800 0x000002A6 Loader.bin 0x00001000 0x0003594E parameter 0x00037000 0x000003BF Image/trust.img 0x00037800 0x00400000 Image/uboot.img 0x00437800 0x00400000 Image/resource.img 0x00837800 0x00606400 Image/misc.img 0x00E3E000 0x0000C000 Image/kernel.img 0x00E4A000 0x00D08C4C Image/boot.img 0x01B53000 0x001354E8 Image/recovery.img 0x01C88800 0x00FB4000 Image/system.img 0x02C3C800 0x28D29000 update-script 0x2B965800 0x000003A5 recover-script 0x2B966000 0x0000010A Unpack firmware OK! ------ OK ------ Unpacking update.img OK. Press any key to quit: |
The files will be in the “output” directory. For our purpose “parameter” file, and especially the last line (CMDLINE) where we will want to adjust the userdata partition […]
$15 Microchip Curiosity Development Board Supports 8-bit PIC Microcontrollers
I’ve just found out Microchip had introduced Curiosity development board a little while ago, in order to let students and others experiment with their 8-bit PIC DIP MCUs, and including MikroElectronika Mikrobus footprint, an interface for Microchip RN4020 module to add Bluetooth Low Energy, as well as other headers and some extra features like buttons, and a potentiometer. Microchip Curiosity board specifications: MCU – PIC MCU socket for 8, 14, and 20-pin micro-controllers with PIC16F1619 pre-installed. Expansion mikroBUS Click Board footprint Microchip RN4020 Bluetooth Module Footprint USB – USB mini-B connector Misc – Master Clear Reset button, potentiometer, LEDs, mTouch button, push button Power Supply 5V via USB 9V using an external power supply (footprints only) 3.3V to 5V external power supply via TP3 and TP4 pins Dimensions – N/A There are over 160 MikroElektronika Click boars on the market now, but only seven are listed with code samples for […]
How to extract kernel.img with mkboot script
As I tried instructions to install Linux on Amlogic S905 Android TV boxes yesterday, I wanted to extract kernel.img file found in Android firmware, but Google did not help that much until I found mkboot part of mkbootimg_tools scripts. But first let’s see how kernel.img is created… Google provide a Python script called mkbootimg that combine the kernel image (e,.g. zImage), a rootfs/ramdisk and the device tree (DTB) file with a command line that looks like:
|
1 |
./mkbootimg --base=0 --kernel_offset=0x01080000 --kernel ${KERNEL} --ramdisk_offset=0x01000000 --ramdisk ./${ROOTFS} --second ${DTBFILE} --output ./kernel.img |
However, AFAIK the company does not provide a “unmkbootimg” script, and mkbootimg can only be used to create kernel.img, not decompile it. But that’s what mkboot does, and it works for kernel.img and recovery.img. Let’s retrieve the necessary files first:
|
1 |
git clone https://github.com/xiaolu/mkbootimg_tools |
mkboot is a bash script so we can use it right away:
|
1 2 3 4 5 6 7 8 9 10 11 |
cd mkbootimg_tools ./mkboot <Unpack and repack boot.img tool> ---------------------------------------------------------------------- Not enough parameters or parameter error! unpack boot.img & decompress ramdisk: mkboot [img] [output dir] mkboot boot.img boot20130905 Use the unpacked directory repack boot.img(img_info): mkboot [unpacked dir] [newbootfile] mkboot boot20130905 newboot.img |
So it can be used both for unpacking and repacking kernel.img to/from the output directory. Let’s run the command […]

