Tiny Core Base > Raspberry Pi
USB gadget kernel module with RPi zero
Rich:
Hi ladnar
You could create a gadget extension (squashfs-tools.tcz required):
--- Code: ---tc@E310:~/pi$ wget http://tinycorelinux.net/9.x/armv6/releases/RPi/src/kernel/4.9.22-piCore_modules.tar.xz
--2020-10-01 22:58:43-- http://tinycorelinux.net/9.x/armv6/releases/RPi/src/kernel/4.9.22-piCore_modules.tar.xz
Resolving tinycorelinux.net... 89.22.99.37
Connecting to tinycorelinux.net|89.22.99.37|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11161928 (11M) [text/plain]
Saving to: '4.9.22-piCore_modules.tar.xz'
4.9.22-piCore_modules.tar.xz 100%[============================================================================================================================>] 10.64M 3.30MB/s in 3.2s
2020-10-01 22:58:46 (3.30 MB/s) - '4.9.22-piCore_modules.tar.xz' saved [11161928/11161928]
tc@E310:~/pi$ tar xf 4.9.22-piCore_modules.tar.xz
tc@E310:~/pi$ mkdir -p package/usr/local/lib/modules/4.9.22-piCore/kernel/drivers/usb
tc@E310:~/pi$ cp -a lib/modules/4.9.22-piCore/kernel/drivers/usb/gadget package/usr/local/lib/modules/4.9.22-piCore/kernel/drivers/usb
tc@E310:~/pi$ mksquashfs package gadget-4.9.22-piCore.tcz
Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on gadget-4.9.22-piCore.tcz, block size 4096.
[============================================================================================================================================================================================================|] 186/186 100%
Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 4096
compressed data, compressed metadata, compressed fragments, no xattrs
duplicates are removed
Filesystem size 253.94 Kbytes (0.25 Mbytes)
36.96% of uncompressed filesystem size (686.99 Kbytes)
Inode table size 946 bytes (0.92 Kbytes)
44.58% of uncompressed inode table size (2122 bytes)
Directory table size 510 bytes (0.50 Kbytes)
54.60% of uncompressed directory table size (934 bytes)
Number of duplicate files found 0
Number of inodes 43
Number of files 30
Number of fragments 0
Number of symbolic links 0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 13
Number of ids (unique uids + gids) 2
Number of uids 1
tc (1001)
Number of gids 1
staff (50)
tc@E310:~/pi$
--- End code ---
Copy gadget-4.9.22-piCore.tcz to your tce directory. Then:
--- Code: ---tce-load -i gadget-4.9.22-piCore
sudo modprobe g_ether
--- End code ---
Check if your modules are loaded:
--- Code: ---lsmod
--- End code ---
ladnar:
Thanks,
I will give it a try, but right now I am "extreme apartment hunting"; I really did not have the time to clog the tinycore/picore pages with my meager experiments; but I did anyway. And now I am paying for it (in stress levels and worry). I'll see you, here, in a week or two when I, like a cat, land on my feet! Maybe I'll have a gadget extension and/or configured-and-rebuilt kernel by then? Maybe I will have some greater grasp of what I am doing, then.
Thanks again for the specific advice / code.
ladnar:
Old link, but I am going to try to absorb two or three chapter tonight.
https://linux.die.net/lkmpg/index.html
this part looks good.
https://linux.die.net/lkmpg/x44.html
Rich:
Hi ladnar
Unless you are planning on learning how to program in C and writing your own kernel modules, I don't think that guide will be
of much help to you.
The instructions listed in reply #50 should take well under 5 minutes. The most time consuming step is the download time
of 4.9.22-piCore_modules.tar.xz. The tce-load step will even run depmod for you since it checks if extensions contain
kernel modules. If you are satisfied it loaded the 5 modules you mentioned in reply #48 loaded, you can:
1. Add gadget-4.9.22-piCore.tcz to your /etc/sysconfig/tcedir/onboot.lst file so the extension gets loaded when you boot.
2. Add modprobe g_ether.ko to your /opt/bootlocal.sh file so the module and its dependencies get loaded when you boot.
ladnar:
Have started C, but as with most other things in life, have been separated from the book that would teach it. I think I still have the pdf somewhere? Thanks Rich. (I already know a fair amount about the process; headers, pre-compile, compile, assembly, object files, linkers, binary blobs, etc. Studied a bit of Barry Brey's textbook on x86, MASM and TASM, circa 2001; and Rodnay Zaks 6502 early 1980s book; and Ritchie and Kernighans "C" classic textbook. tarted to read Two Tennenbaum books, one on distributed systems, the other one was the one Torvalds read before he wrote Linux. Also had nice book on Binary dissasembly; I forget the author? A recent book from stach press, out of Frisco? But you're right. I can't know everything, at least not ALL AT ONCE. So "C" might have to wait You be happy to see, below, that I have maybe figured out my problem --besides my exuberance outstripping my talent. I think the latter caught up to the former, finally.)
First things first. I looked at my old posts (under "doctor anonymous" handle ) and realized, I already half-solved this problem, about 9 months ago! But I was moving apartments then, too, and so I had lost track of my progress. The good doctor was working with usbboot, and got it half-functional.
Now, I think I have figured out this modprobe stuff, and I think I know why it was working with Raspbian and not with piCore. Its the persistence thing. I guess "persistence" is not the thing I need, per se. (A GOOD shell script FIRST, then persistence of that script.).
I tried putting the following thing into onboot.lst ; It will go there, but its useless ! "sudo modprobe g_ether". But the simple shell scripts I made, also placed in my onboot.lst , for "Meyer's Strong AI Standard Directories" (MSSAID), execute fine. So, something like that is needed here. I think I can probably solve user/member bot's problem too, with "serial" mode. (for the moment, please ignore the impertinence of a biologist walking in and telling the experts that LSB/FHS has to be changed (to include MMSAID). I know LSB has a history, but its also come a long way, and has much further to go!)
I don't have time today to look into serial, but will write g_ether script and post it here (if my idea works). Also, depmod -a stymied me a few time, because the chmod permissions for modules.dep are 755 ; I was going to chmod it to 777, and then back again, but then I remembered just to sudo it.
That link ( https://linux.die.net/lkmpg/x44.html ) helped alot to explain modules, and another page I stumbled on with some good example on how to actually use, lsmod, modprobe, depmod, and modules.dep . It wasn't rocket science, and I think a clutter and junk in my brain just reached critical mass.
It was also important to hear about the difference between insmod and modprobe, and the function of the depmode and modules.dep in making modprobe much easier and convenient than insmod.
Anyhoo, I should go write the script. It will basically just load all the modules that I have been typing in one at a time. I'll put the script in the onboot.lst and it will execute on startup (instead of the modules erasing / reverting, when I shut the power off). That's what was happening. I got all the modprobe stuff done, but then would shut it off to switch the wires around and hook it up to the master board. For whatever reason, I figured its better to turn master and slave b oard on simultaneously, so they both "negotiate the bus" at the same time. Maybe not necessary, but I considered it prudent (funny things can happen with USB and power and hubs and etc? Funny, buggy things!). But in this case, shutting off power was undoing the modules.
Also, anyone stumbling on this post who doesn't want to read the previous one hundred (20 or so) should note that I have placed five modules in the appropriate /lib/modules/4.9.22-piCore/ .../ folders, and placed the path of those folders in the /opt/.filetool,lst , and then typed the backup command. This seems to have worked for these five files.
g_ether.ko ; usb_f_rndis.ko ; u_ether.ko ; udc-core.ko and libcomposite.ko
The script will just be this, I think:
--- Code: ---#!/bin/sh
sudo modprobe g_ether
exit
--- End code ---
I wonder if this could be put in cmdline.txt, because raspbian has that line about "load-modules,g_ether" or whatever? Maybe that command actually works? Maybe all this time, that is all I had to do? I will try it my way first, and if that doesn't work, I will try the raspbain cmdline.txt edit.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version