Linux Kernel Stuff Entry: Digging into UHCI USB host driver. Date: Sat May 19 09:45:32 EDT 2012 drivers/usb/core/message.c There's a call to dev_dbg(). How to switch on debugging? Hmmm.. looks like this was part of the linux core, not a module. I tried to use the "debug" kernel command line parameter but that doesn't seem to do anything. Now trying this in config: -CONFIG_USB=y -# CONFIG_USB_DEBUG is not set +CONFIG_USB=m +CONFIG_USB_DEBUG=y Entry: Minimal image Date: Sat May 19 09:52:40 EDT 2012 How to create a minimal linux image for a certain machine from say a list of modules and a generic kernel config? Entry: Debian Kernels Date: Sat May 19 10:49:07 EDT 2012 Modifying linux-2.6-2.6.32 version 2.6.32-45 Keep the original one! In [1] it mentions abi.abiname which I couldn't find, so I skipped that one. Q: Where does the config come from? It looks like it's simpler to just copy the config for my arch to .config + modifications and use make-kpkg. cp debian/Config/config.686 .config Wait a minute. It has almost everything disabled! Maybe it's just the wrong one: cp debian/Config/config.i686 .config Nope, that's also mostly empty. [1] http://wiki.debian.org/HowToRebuildAnOfficialDebianKernelPackage Entry: USB BUG() backtrace Date: Sun May 20 17:29:15 EDT 2012 May 20 17:28:09 broebel kernel: [ 1668.978402] ------------[ cut here ]------------ Put a BUG() message in the USB code to see the call trace. Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.978402] ------------[ cut here ]------------ May 20 17:28:09 broebel kernel: [ 1668.978425] kernel BUG at drivers/usb/core/message.c:72! May 20 17:28:09 broebel kernel: [ 1668.978446] invalid opcode: 0000 [#1] PREEMPT SMP Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.978446] invalid opcode: 0000 [#1] PREEMPT SMP May 20 17:28:09 broebel kernel: [ 1668.978473] last sysfs file: /sys/class/power_supply/BAT0/energy_full Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.978473] last sysfs file: /sys/class/power_supply/BAT0/energy_full May 20 17:28:09 broebel kernel: [ 1668.978492] Modules linked in: uhci_hcd ehci_hcd usbmon usbcore autofs4 fuse nfsd exportfs nfs lockd nfs_acl auth_rpcgss sunrpc loop snd_nm256 snd_ac97_codec ac97_bus snd_pcm_oss snd_mixer_oss snd_pcm snd_page_alloc snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi 8139too snd_seq_midi_event mii snd_seq snd_timer snd_seq_device joydev snd pcmcia soundcore i2c_piix4 shpchp yenta_socket video psmouse pci_hotplug rsrc_nonstatic ac intel_agp parport_pc processor battery button i2c_core output pcmcia_core parport pcspkr serio_raw evdev dcdbas ext3 jbd mbcache ide_cd_mod ide_gd_mod cdrom ata_generic ata_piix libata scsi_mod ide_pci_generic thermal piix floppy thermal_sys ide_core [last unloaded: usbcore] May 20 17:28:09 broebel kernel: [ 1668.978908] May 20 17:28:09 broebel kernel: [ 1668.978933] Pid: 2518, comm: khubd Not tainted (2.6.32-usbdbg #6) Latitude CPi A300ST May 20 17:28:09 broebel kernel: [ 1668.978959] EIP: 0060:[] EFLAGS: 00010286 CPU: 0 May 20 17:28:09 broebel kernel: [ 1668.979063] EIP is at usb_start_wait_urb+0x123/0x141 [usbcore] May 20 17:28:09 broebel kernel: [ 1668.979087] EAX: 00000055 EBX: cda8c6a0 ECX: cef03e50 EDX: d0eda011 May 20 17:28:09 broebel kernel: [ 1668.979109] ESI: 00000000 EDI: cef03eb8 EBP: 00001388 ESP: cef03e58 May 20 17:28:09 broebel kernel: [ 1668.979132] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 May 20 17:28:09 broebel kernel: [ 1668.979159] Process khubd (pid: 2518, ti=cef02000 task=ce2e0560 task.ti=cef02000) Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.979159] Process khubd (pid: 2518, ti=cef02000 task=ce2e0560 task.ti=cef02000) May 20 17:28:09 broebel kernel: [ 1668.979177] Stack: Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.979177] Stack: May 20 17:28:09 broebel kernel: [ 1668.979189] 00000020 ce2ecc00 cec00500 00000202 00000202 00000000 00000303 cef03e74 May 20 17:28:09 broebel kernel: [ 1668.979238] <0> cef03e74 ffffffac cda8c6a0 ceea1c40 ce2ecc00 00000000 d0eced74 d0eda07b May 20 17:28:09 broebel kernel: [ 1668.979290] <0> d0ed9fa6 d0eda05e d0ed9fa6 c1264d5a 062ecc00 00400100 80000080 80ad9c00 May 20 17:28:09 broebel kernel: [ 1668.979346] Call Trace: Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.979346] Call Trace: May 20 17:28:09 broebel kernel: [ 1668.979418] [] ? usb_control_msg+0x14e/0x187 [usbcore] May 20 17:28:09 broebel kernel: [ 1668.979463] [] ? _spin_lock_irqsave+0x1c/0x35 May 20 17:28:09 broebel kernel: [ 1668.979520] [] ? printk+0xe/0x12 May 20 17:28:09 broebel kernel: [ 1668.979579] [] ? hub_port_init+0x2ba/0x666 [usbcore] May 20 17:28:09 broebel kernel: [ 1668.979645] [] ? hub_thread+0x7c8/0xe40 [usbcore] May 20 17:28:09 broebel kernel: [ 1668.979687] [] ? autoremove_wake_function+0x0/0x29 May 20 17:28:09 broebel kernel: [ 1668.979746] [] ? hub_thread+0x0/0xe40 [usbcore] May 20 17:28:09 broebel kernel: [ 1668.979799] [] ? kthread+0x5f/0x64 May 20 17:28:09 broebel kernel: [ 1668.979830] [] ? kthread+0x0/0x64 May 20 17:28:09 broebel kernel: [ 1668.979876] [] ? kernel_thread_helper+0x7/0x10 May 20 17:28:09 broebel kernel: [ 1668.979894] Code: e5 9f ed d0 e8 23 41 39 f0 83 c4 20 eb 21 ff 74 24 24 68 a6 9f ed d0 68 11 a0 ed d0 e8 0b 41 39 f0 83 c4 0c 83 7c 24 24 00 74 04 <0f> 0b eb fe 85 ff 74 05 8b 43 54 89 07 89 d8 e8 95 f0 ff ff 89 Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.979894] Code: e5 9f ed d0 e8 23 41 39 f0 83 c4 20 eb 21 ff 74 24 24 68 a6 9f ed d0 68 11 a0 ed d0 e8 0b 41 39 f0 83 c4 0c 83 7c 24 24 00 74 04 <0f> 0b eb fe 85 ff 74 05 8b 43 54 89 07 89 d8 e8 95 f0 ff ff 89 May 20 17:28:09 broebel kernel: [ 1668.980181] EIP: [] usb_start_wait_urb+0x123/0x141 [usbcore] SS:ESP 0068:cef03e58 Message from syslogd@broebel at May 20 17:28:09 ... kernel:[ 1668.980181] EIP: [] usb_start_wait_urb+0x123/0x141 [usbcore] SS:ESP 0068:cef03e58 May 20 17:28:09 broebel kernel: [ 1668.982596] ---[ end trace 712d00f1e5bf0f8a ]--- Entry: Modifying USB code to give up at first sign of trouble. Date: Sun May 20 17:32:54 EDT 2012 In drivers/usb/hub.c : #define PORT_RESET_TRIES 5 #define SET_ADDRESS_TRIES 2 #define GET_DESCRIPTOR_TRIES 2 usb_get_configuration -> usb_get_descriptor Entry: Browsing arch/arm sources Date: Wed Oct 26 19:51:12 EDT 2016 Q: - difference between plat and mach? - where to find VF61 support? (mach-imx) - does 3.0 have ARM idle mode WFI? ARM: vf610m4: Add Vybrid Cortex-M4 support https://lwn.net/Articles/624242/ patches are to arch/arm/mach-imx Porting to ARM (2010) http://free-electrons.com/doc/kernel-porting.odp https://www.kernel.org/doc/Documentation/arm/README ARCH=arm make menuconfig multiple platforms freescale i.MX family Vybrid Family VF610 CPU power management CPU IDLE ARM CPU IDLE drivers Generic ARM/ARM64 idle driver Note that timesys 3.0 does not have that option. mach- are machine-specific non-driver files Clear that it's way too much work to get the config right from scratch. Start from an existing config specific to vybrid and tweak it. ARM idle uses WFI instruction http://stackoverflow.com/questions/15058781/how-does-linux-kernel-wake-idle-processor-up-when-new-task-created http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/arm/idle-states.txt https://github.com/avoltz/linux-vybrid/commits/3.0-mvf Entry: timesys 3.0 mach-mvf idle Date: Wed Oct 26 20:37:44 EDT 2016 - Q what is the wakeup source? https://linuxplumbersconf.org/2015/ocw//system/presentations/3051/original/wakeup_config.pdf i want to wakeup on lan https://community.nxp.com/thread/323832 https://freescale.jiveon.com/thread/325000 Grep for "wfi" -> mvf_suspend.S Makefile: obj-$(CONFIG_ARCH_MVFA5) += clock.o mvf_suspend.o which is set in config the mvf_suspend() function preps and executs wfi. It is called in pm.c which executes it from sram. suspend_in_iram() which is called from mvf_suspen_enter() So all of this is for the deeper sleep modes. -Q: is wfi called in cpu idle loop? grepping for pm_idle in arch/arm doesn't turn anything up for mvf. can't find it in mainline 4.8.4 either -- only imx http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/289173.html http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/289822.html >> Power measurement (Colibri VF61, whole module): >> - Idle: 540mW >> - LP-RUN: 220mW (standby) >> - STOP: 200mW (mem) That patch mentions that code is not excuting from sram yet, while mainline does have that. Entry: Toradex linux pages are very detailed Date: Sat Oct 29 04:39:06 EDT 2016 http://developer.toradex.com/software/linux/linux-software http://developer.toradex.com/knowledge-base/suspend-resume-(linux) Entry: Add support for new board based on device tree config in forked tree Date: Sun Nov 6 12:06:46 EST 2016 Example: http://git.toradex.com/linux-toradex.git tags/Colibri_VF_LinuxImageV2.6.1Beta1_20161001 7ecc29c26b343db3ac3b533d77845769d12950a2 checkout -b myboard 1. first verify build the orginal kernel for particular board export ARCH=arm export PATH=~/lib/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/:$PATH export CROSS_COMPILE=arm-linux-gnueabihf- make colibri_vf_defconfig make 2. copy the original file, possibly inlining some of the included dtsi files, and edit it to reflect hardware cd linux-toradex/arch/arm/boot/dts cp vf610-colibri-eval-v3.dts myboard.dts 3. build the dtb manually make myboard.dtb 4. optionally, add it to config here: linux-toradex/arch/arm/boot/dts/Makefile: dtb-$(CONFIG_SOC_VF610) += \ vf500-colibri-eval-v3.dtb \ vf610-colibri-eval-v3.dtb \ vf610m4-colibri.dtb \ vf500-colibri-dual-eth.dtb \ vf610-colibri-dual-eth.dtb \ vf610-cosmic.dtb \ - vf610-twr.dtb + vf610-twr.dtb \ myboard.dtb https://www.raspberrypi.org/documentation/configuration/device-tree.md http://www.armadeus.org/wiki/index.php?title=Kernel-with-device-tree Entry: UBI & UBIFS Date: Wed Nov 16 20:20:06 EST 2016 I want to write the dtb volume on a UBI device. http://free-electrons.com/blog/creating-flashing-ubi-ubifs-images/ http://www.linux-mtd.infradead.org/faq/ubi.html ubiupdatevol /dev/ubi0_1 board.dtb root@colibri-vf:/dev# ubinfo -a UBI version: 1 Count of UBI devices: 1 UBI control device major/minor: 10:58 Present UBI devices: ubi0 ubi0 Volumes count: 3 Logical eraseblock size: 126976 bytes, 124.0 KiB Total amount of logical eraseblocks: 4075 (517427200 bytes, 493.5 MiB) Amount of available logical eraseblocks: 0 (0 bytes) Maximum count of volumes 128 Count of bad physical eraseblocks: 5 Count of reserved physical eraseblocks: 75 Current maximum erase counter value: 2 Minimum input/output unit size: 2048 bytes Character device major/minor: 247:0 Present volumes: 0, 1, 2 Volume ID: 0 (on ubi0) Type: static Alignment: 1 Size: 67 LEBs (8507392 bytes, 8.1 MiB) Data bytes: 4744320 bytes (4.5 MiB) State: OK Name: kernel Character device major/minor: 247:1 ----------------------------------- Volume ID: 1 (on ubi0) Type: static Alignment: 1 Size: 2 LEBs (253952 bytes, 248.0 KiB) Data bytes: 26611 bytes (26.0 KiB) State: OK Name: dtb Character device major/minor: 247:2 ----------------------------------- Volume ID: 2 (on ubi0) Type: dynamic Alignment: 1 Size: 3925 LEBs (498380800 bytes, 475.3 MiB) State: OK Name: rootfs Character device major/minor: 247:3 Entry: minimal netboot Date: Sun Nov 27 09:02:20 EST 2016 Ingredients: - board-specific bootloader + config - board-specific kernel + modules - (mostly) shared read-only NFS make this work on pi first. Question about securing this: should use initrd that is stored locally, so doesn't work together with updatable kernels. Entry: beaglebone, pru, devicetree Date: Wed May 16 09:11:56 EDT 2018 Confusing stuff. Some notes. Device tree is just a data structure. The structure usually reflects some hierarchy of the chip or driver, but otherwise seems rather arbitrary. The structure is queried from the driver. It appears the driver's probe routine already has the node reference, so this is likely gathered from the 'compatible' part. GPIOs are not pins. Pins seem to always be behind a multiplexer which is abstracted in Linux behind a 'pinctrl' interface. GPIOs are a separate entity inside the chip, which can be muxed to pins, or not. Entry: capemgr Date: Wed May 16 09:20:16 EDT 2018 https://elinux.org/Capemgr A kind of "plug and play", where e.g. expansion board I2C EEPROM is queried to determine installed boards, to then guide loading of device tree overlays. Entry: Device tree Date: Wed May 16 10:28:48 EDT 2018 Node names and references. What does this mean? &am33xx_pinmux { ... } It appears this adds nodes to the existing node "am33xx_pinmux". E.g. that node is defined in am33xx.dtsi: / { ocp: ocp { l4_wkup: l4_wkup@44c00000 { scm: scm@210000 { am33xx_pinmux: pinmux@800 { } } } } } So the general dts syntax seems to be: label: node_name[@address] The @address is a naming convention. The address doesn't seem to be used numerically anywhere. The whole string node_name@address is the node identifier. These need to be unique among siblings. label is a globally unique label. &label string reflecting full path <&label> phandle Q: What does "compatible" mean? https://elinux.org/Device_Tree_Usage#Understanding_the_compatible_Property It is the key an operating system uses to decide which device driver to bind to a device. (* 12 20000 16) Entry: PIN CONTROL Date: Wed Jul 18 16:12:49 EDT 2018 What do I understand? - the interface is to set a register to a value - somehow, a subsystem is linked to a pin configuration What not? - how to switch e.g. between GPIO and SPI? E.g. below, the pruss_soc_bus node references pinctrl-0, which is a node inside the am33xx_pinmux node. I'm guessing that how this works is that when the pruss drivers is initialized, it will call into the pinctrl subsystem to set those pins. &pruss_soc_bus { status = "okay"; pruss@4a300000 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&hatd_pru_pins>; pru@4a334000 { status = "okay"; }; pru@4a338000 { status = "okay"; }; }; }; &am33xx_pinmux { hatd_pru_pins: hatd_pru_pins { pinctrl-single,pins = < // Comments annotate names from am335-bone-common-universal-pins.dtsi // It seems best just to copy. FIXME: generate this file. 0x0a0 0x05 // P8_45_pruout_pin 0x0a4 0x05 // P8_46_pruout_pin >; }; https://www.kernel.org/doc/Documentation/pinctrl.txt - PIN CONTROLLER (e.g. am33x_pinmux) - PIN (unsigned integer, name, ...) mount -t debugfs none /sys/kernel/debug/ /sys/kernel/debug/pinctrl/44e10800.pinmux/pins - groups - PIN MUX, FUNCTIONS Entry: Map from minmux/pinctrl pin number to ball name? Date: Wed Jul 18 16:55:02 EDT 2018 This can probably be done by address? EDIT: Yes: addr-4 Anyways, got it. Entry: Next? Date: Wed Jul 18 22:30:01 EDT 2018 Rust bitbang frequency test.