Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
On Thu, Mar 25, 2010 at 5:18 AM, RHS Linux User wrote: > > Hi, > > I often use a simple bit-bang function at some high buad rate and one > gpio pin. I hook a serial terminal to it. Depending on CPU speed, etc. > interrupts may have to be disabled during the time the character is > actually being sent. One character at 115,200 is 0.1ms so unless the CPU > is very busy with time dependent stuff, most applications don't seem to > mind that much. > > As an additional variation of this scheme, I make the pin > bi-directional and hook my full software debugger to it. I can peek, poke > and monitor memory in more or less real time. I use OpenOCD with a JTAG USB dongle and have gdb connect to the gdb server OpenOCD provides. This works great for things like the kernel, userspace programs etc. but I don't know how to go about using it to debug shell scripts. I've heard there is a bash debugger but I doubt that will help with ash built into BusyBox. Debugging shell scripts on a embedded target just isn't something I've ever needed to touch until now. Thanks for the ideas. Regards, Brian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
Hi, I often use a simple bit-bang function at some high buad rate and one gpio pin. I hook a serial terminal to it. Depending on CPU speed, etc. interrupts may have to be disabled during the time the character is actually being sent. One character at 115,200 is 0.1ms so unless the CPU is very busy with time dependent stuff, most applications don't seem to mind that much. As an additional variation of this scheme, I make the pin bi-directional and hook my full software debugger to it. I can peek, poke and monitor memory in more or less real time. Works great. Saves LOTS of time. And makes things really clear. This feature would be a good add to OpenWRT in my copious spare time :)). regards, Wiz On Wed, 24 Mar 2010, Ferenc Wagner wrote: > Daniel Dickinson writes: > > > You won't see anything from preinit with set -x because when preinit is > > first called there is no stdin/stdout. One of the things preinit does > > is attach itself to a terminal, if there is one (otherwise it just > > connects to a pseudo-terminal) > > Would putting /dev/console in the root filesystem solve this? Fakeroot > could be used for that without requiring real root for image generation. > -- > Thanks, > Feri. > ___ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel > ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
Daniel Dickinson writes: > You won't see anything from preinit with set -x because when preinit is > first called there is no stdin/stdout. One of the things preinit does > is attach itself to a terminal, if there is one (otherwise it just > connects to a pseudo-terminal) Would putting /dev/console in the root filesystem solve this? Fakeroot could be used for that without requiring real root for image generation. -- Thanks, Feri. ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
> You won't see anything from preinit with set -x because when preinit is > first called there is no stdin/stdout. Ah, I didn't think of that! > >> >> I didn't think about running wireshark to capture the script output >> ... I'll have to look into that. I'm well versed in wireshark. >> >> What is this 'pure' /jffs envrionment? Is it possible to setup the >> union so that 'any' file can be modified? That is kind of what I was >> expecting to have but I realize some of the preinit stuff has to run >> from squashfs because the union isn't established that early in the >> startup. >> > > No not pure /jffs - that's just the mountpoint when using a jffs2 > overlay over the squashfs. It is possible to build/flash images that > don't have a squashfs at all, and which store everything on a jffs2 > filesystem (no overlay). This images are larger than the squashfs > images so you may not have enough flash memory for one of them. Ah, yes. I started off with a all JFFS2 partition but switched to squashfs for speed/performance issues. I still need persistence so I back ported mini_fo to my kernel and am trying to learn the preinit scripts to understand how the squashfs & jffs2 filesystems are manipulated and then combined. I had hoped that it was possible to create the union in such a way that the startup scrips in squashfs rootfs could be modified and the version in /jffs used but that might not be possible. I'm not real experienced on the finer points of using a union fs in a embedded environment yet. I thought that it might be possible to set the union up so that any file in the squashfs could be edited. That may be true but in the case of the startup scripts ... the /jffs version might not be used as the union isn't setup yet. These limits are the kind of things I'm trying to figure out. Regards, Brian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
On Tue, 2010-03-23 at 09:04 -0400, Brian Hutchinson wrote: > Thanks to everyone for the great suggestions! > > Since I'm new at going this deep into shell debugging (and almost > never on a embedded target) I'll have to check out each of these > suggestions as I've never heard of some of them. > > Is it possible to start preinit with -x and redirect the output to the > console or network? I have minicom running on the serial port and see > some of the echo statements in the script ... I just don't see the -x > debug info I was hoping to see. You won't see anything from preinit with set -x because when preinit is first called there is no stdin/stdout. One of the things preinit does is attach itself to a terminal, if there is one (otherwise it just connects to a pseudo-terminal) > > I didn't think about running wireshark to capture the script output > ... I'll have to look into that. I'm well versed in wireshark. > > What is this 'pure' /jffs envrionment? Is it possible to setup the > union so that 'any' file can be modified? That is kind of what I was > expecting to have but I realize some of the preinit stuff has to run > from squashfs because the union isn't established that early in the > startup. > No not pure /jffs - that's just the mountpoint when using a jffs2 overlay over the squashfs. It is possible to build/flash images that don't have a squashfs at all, and which store everything on a jffs2 filesystem (no overlay). This images are larger than the squashfs images so you may not have enough flash memory for one of them. -- And that's my crabbing done for the day. Got it out of the way early, now I have the rest of the afternoon to sniff fragrant tea-roses or strangle cute bunnies or something. -- Michael Devore GnuPG Key Fingerprint 86 F5 81 A5 D4 2E 1F 1C http://gnupg.org The C Shore (Daniel Dickinson's Website) http://cshore.is-a-geek.com signature.asc Description: This is a digitally signed message part ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
On Tue, Mar 23, 2010 at 9:04 AM, Brian Hutchinson wrote: > Thanks to everyone for the great suggestions! > > Since I'm new at going this deep into shell debugging (and almost > never on a embedded target) I'll have to check out each of these > suggestions as I've never heard of some of them. > > Is it possible to start preinit with -x and redirect the output to the > console or network? I have minicom running on the serial port and see > some of the echo statements in the script ... I just don't see the -x > debug info I was hoping to see. > If preinit is called with "/bin/sh preinit.sh" it would ignore the -x. Put "set -x" as the second line, unless -x is disabled in our version of busybox (I don't remember). If that doesn't start spamming the crap out of your terminal I guess you have to use the other suggestions. You can also add set -x/set +x to turn the spamming on and off so your not rapped by the entire boot sequence. ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
Thanks to everyone for the great suggestions! Since I'm new at going this deep into shell debugging (and almost never on a embedded target) I'll have to check out each of these suggestions as I've never heard of some of them. Is it possible to start preinit with -x and redirect the output to the console or network? I have minicom running on the serial port and see some of the echo statements in the script ... I just don't see the -x debug info I was hoping to see. I didn't think about running wireshark to capture the script output ... I'll have to look into that. I'm well versed in wireshark. What is this 'pure' /jffs envrionment? Is it possible to setup the union so that 'any' file can be modified? That is kind of what I was expecting to have but I realize some of the preinit stuff has to run from squashfs because the union isn't established that early in the startup. Regards, Brian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
On Mon, 2010-03-22 at 12:24 -0400, Stefan Monnier wrote: > Another option might be to send that debug output to the network as is > done in preinit_net_echo and "read" it via tcpdump. You can also use socat to receive the udp broadcasts without exiting after the first one. -- And that's my crabbing done for the day. Got it out of the way early, now I have the rest of the afternoon to sniff fragrant tea-roses or strangle cute bunnies or something. -- Michael Devore GnuPG Key Fingerprint 86 F5 81 A5 D4 2E 1F 1C http://gnupg.org The C Shore (Daniel Dickinson's Website) http://cshore.is-a-geek.com signature.asc Description: This is a digitally signed message part ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
On Sun, 2010-03-21 at 20:41 -0400, Brian Hutchinson wrote: > Hi, > > I've never needed to really get into the startup scripts much but now > I need to try and understand how the mini_fo union gets set up so I'm > trying to learn the startup scripts like preinit. > > I'm using a Pronghorn SBC (ixp-42xx) and I thought that maybe if I > edited preinit and put #!/bin/sh -x that I could turn on debugging and > see what the scripts were doing via the serial console. > > That didn't work so well. How you all debug startup scripts? It depends on the error. If the problem is that preinit doesn't start at all, that usually indicates a syntax error or some such in the start up scripts, so on the host, I fire up dash, and do something like: for script in *; do . $script done in the build_dir/target.../root.../lib/preinit directory If there is a syntax error it will emit an error message and it can be fixed. Errors that prevent successful sourcing of files will cause preinit to die. > > I can't change preinit from the target can I? I tried but I guess it I was going to suggest using a 'pure' jffs image, but I realized that defeats the purpose of what you are trying to test. For a squashfs, the preinit runs from squashfs, not jffs (because mounting the jffs is part of the preinit functionality; probably the most important). > isn't using the one from /jffs and is using the one from /rom. I had > to rebuild the image to get my preinit changes to execute on startup. > Stefan had good suggestions for the rest. -- And that's my crabbing done for the day. Got it out of the way early, now I have the rest of the afternoon to sniff fragrant tea-roses or strangle cute bunnies or something. -- Michael Devore GnuPG Key Fingerprint 86 F5 81 A5 D4 2E 1F 1C http://gnupg.org The C Shore (Daniel Dickinson's Website) http://cshore.is-a-geek.com signature.asc Description: This is a digitally signed message part ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Howto debug init scripts like preinit?
> I've never needed to really get into the startup scripts much but now > I need to try and understand how the mini_fo union gets set up so I'm > trying to learn the startup scripts like preinit. When I ad to fiddle with this part of the code, I'd add some echo blabla >>/tmp/mydebug in those scripts and then read the /tmp/mydebug file (of course, this only worked in those cases where the boot script did end up setting up my router in such a way that I was able to log in to look at the damn file). Another option might be to send that debug output to the network as is done in preinit_net_echo and "read" it via tcpdump. Stefan ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel