Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 10-19-2021, 03:36 PM   #16
wishindo
Member
wishindo began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2021
Location: Florida, USA
Device: Kindle Keyboard w/ 3G (k3g), Likebook Mars (T80D)
Quote:
Originally Posted by Quoth View Post
...I never heard of any common TC issue with Debian.
I'll try Debian then.

Quote:
Originally Posted by Quoth View Post
However, I'd rather buy a new Kobo or Kindle and use a phone as a 4G to WiFi hot spot than do this.
Wrong thread. This thread is for using the modem slot to add to the 3GB of storage the Kindle Keyboard has. The 4G modem thread is here.

(End of reply to Quoth)

Using the toolchain gcc-arm-linux-gnueabi from apt on Debian, the build now throws this error:
Code:
/tmp/ccjIB5v8.s: Assembler messages:
/tmp/ccjIB5v8.s:1045: Error: .err encountered
make[1]: *** [scripts/Makefile.build:223: arch/arm/kernel/sys_oabi-compat.o] Error 1
make: *** [Makefile:847: arch/arm/kernel] Error 2
It's different from what Ubuntu gets stuck on, I wonder why?
wishindo is offline   Reply With Quote
Old 10-19-2021, 03:52 PM   #17
katadelos
rm -rf /
katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.
 
Posts: 219
Karma: 3333683
Join Date: Nov 2019
Location: United Kingdom
Device: K5, KT, KT2, KT3, KT4, KV, PW2, PW3, PW4, PW5
Quote:
Originally Posted by wishindo View Post
Disabled the initramfs and now the kernel build errors at
Code:
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
arch/arm/kernel/built-in.o: In function `sys_mmap2':
io.c:(.text+0xc08): undefined reference to `do_mmap2'
Makefile:778: recipe for target '.tmp_vmlinux1' failed
make: *** [.tmp_vmlinux1] Error 1
I couldn't find anything conclusive about this online. Supposedly, the error means we tried to use a function that wass never coded, but io.c doesn't contain any instances of "do", "sys", or "mm" according to nano.
Had a look at this last night, this patch should fix your issue.

Code:
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 0128687b..b0daaab2 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -35,7 +35,7 @@ extern unsigned long do_mremap(unsigned long addr, unsigned long old_len,
                               unsigned long new_addr);
 
 /* common code for old and new mmaps */
-inline long do_mmap2(
+extern inline long do_mmap2(
        unsigned long addr, unsigned long len,
        unsigned long prot, unsigned long flags,
        unsigned long fd, unsigned long pgoff)
diff --git a/kernel/timeconst.pl b/kernel/timeconst.pl
index eb51d76e..04612394 100644
--- a/kernel/timeconst.pl
+++ b/kernel/timeconst.pl
@@ -370,7 +370,7 @@ if ($hz eq '--can') {
        }
 
        @val = @{$canned_values{$hz}};
-       if (!defined(@val)) {
+       if (!@val) {
                @val = compute_values($hz);
        }
        output($hz, @val);
Quote:
Originally Posted by wishindo View Post
I noticed I never said what toolchain I'm using now. I'm now using gcc-arm-linux-gnueabi from the default repositories for apt, as I made a new Ubuntu instance to have a clean slate to work with between posts #7 and #8.
One reason why the default Ubuntu toolchains aren't great for this kind of thing is because of the specific glibc version requirements across the range of the devices. The Ubuntu ones aren't terrible for virt targets but for Kindle stuff, I use either the toolchains provided by NiLuJe or custom ones generated by an OpenWRT fork that I'm adapting for Kindle.

You can build the koxtoolchains on Ubuntu, you just need to make sure that you've got all of the dependencies installed:

Code:
# From this crosstools-ng dockerfile: https://github.com/crosstool-ng/crosstool-ng/blob/0528a9d744cc95aac3df40d5a1666f0a1051cf5d/testing/docker/ubuntu18.04/Dockerfile
apt-get install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
    python3-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip \
    patch libstdc++6 rsync

# From the dependency list on the koxtoolchains repo:
sudo apt-get install build-essential autoconf automake bison flex gawk libtool libtool-bin libncurses-dev curl file git gperf help2man texinfo unzip wget
katadelos is offline   Reply With Quote
Advert
Old 10-19-2021, 05:20 PM   #18
wishindo
Member
wishindo began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2021
Location: Florida, USA
Device: Kindle Keyboard w/ 3G (k3g), Likebook Mars (T80D)
Quote:
Originally Posted by katadelos View Post
Had a look at this last night, this patch should fix your issue.

code snipped
SUCCESS! The kernel now builds with that patch applied (but patch complains about unexpected end of file so I applied it by hand). Now the Kindle kernel complains about unknown symbols in the modules like usb_storage: Unknown symbol scsi_add_host, for example.

Also I couldn't find Module.symvers anywhere on the kindle. dmesg included complaints of no symbol verisons, which are enabled.
Code:
root@kindle root# cat /proc/config.gz | gzip -cd | grep -i modversions
CONFIG_MODVERSIONS=y
Hmm, could I just simply replace the kernel on the Kindle, with one that has baked-in SCSI and USB mass storage support, avoiding module problems?
wishindo is offline   Reply With Quote
Old 10-19-2021, 05:45 PM   #19
katadelos
rm -rf /
katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.
 
Posts: 219
Karma: 3333683
Join Date: Nov 2019
Location: United Kingdom
Device: K5, KT, KT2, KT3, KT4, KV, PW2, PW3, PW4, PW5
Quote:
Originally Posted by wishindo View Post
SUCCESS! The kernel now builds with that patch applied (but patch complains about unexpected end of file so I applied it by hand). Now the Kindle kernel complains about unknown symbols in the modules like usb_storage: Unknown symbol scsi_add_host, for example.
Which kernel modules have you built so far? You can find which kernel module provides which symbol by grepping through the kernel sources and checking Module.symvers - e.g for that particular error, you need to insmod scsi_mod.ko first.

Quote:
Originally Posted by wishindo View Post
Hmm, could I just simply replace the kernel on the Kindle, with one that has baked-in SCSI and USB mass storage support, avoiding module problems?
You could, I'd advise having a serial adapter and some means of recovery at hand before flashing a custom kernel though.
katadelos is offline   Reply With Quote
Old 10-19-2021, 07:27 PM   #20
wishindo
Member
wishindo began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2021
Location: Florida, USA
Device: Kindle Keyboard w/ 3G (k3g), Likebook Mars (T80D)
Quote:
Originally Posted by katadelos View Post
Which kernel modules have you built so far? You can find which kernel module provides which symbol by grepping through the kernel sources and checking Module.symvers - e.g for that particular error, you need to insmod scsi_mod.ko first.
scsi_mod: disagrees about version of symbol dump_stack
scsi_mod: Unknown symbol dump_stack

The solution to this seems to be use Module.symvers to build the modules against, but find / -name Module.symvers returns nothing. I might flash a kernel if we can't get the symbol versions.

Quote:
Originally Posted by katadelos View Post
You could, I'd advise having a serial adapter and some means of recovery at hand before flashing a custom kernel though.
I have many USB to UART adapters (including a Bus Pirate v3.6), but what does "some means of recovery" refer to? Also, where is the serial port? Didn't see any labeled test points on the mainboard when I looked at mine.
wishindo is offline   Reply With Quote
Advert
Old 10-20-2021, 06:51 PM   #21
katadelos
rm -rf /
katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.katadelos ought to be getting tired of karma fortunes by now.
 
Posts: 219
Karma: 3333683
Join Date: Nov 2019
Location: United Kingdom
Device: K5, KT, KT2, KT3, KT4, KV, PW2, PW3, PW4, PW5
Quote:
Originally Posted by wishindo View Post
scsi_mod: disagrees about version of symbol dump_stack
scsi_mod: Unknown symbol dump_stack

The solution to this seems to be use Module.symvers to build the modules against, but find / -name Module.symvers returns nothing. I might flash a kernel if we can't get the symbol versions.
A couple of things that you should do to troubleshoot this:
  • What is the output of uname -a and modinfo ${YOUR_KERNEL_MODULE}? The vermagic field from modinfo should match the kernel metadata exactly
  • Diff (git diff --no-index config_a config_b) the .config generated from the defconfig for your device on your build PC and the config from /proc/ on the Kindle. Are any config options set on the config from the Kindle that are not set on the config from your build environment?

This article might be helpful too - there's a bit about extracting Modules.symvers from a zImage (you can get this from a uImage by chopping off the first 64 bytes IIRC) : Building a Linux kernel module without the exact kernel headers

Quote:
Originally Posted by wishindo View Post
I have many USB to UART adapters (including a Bus Pirate v3.6), but what does "some means of recovery" refer to? Also, where is the serial port? Didn't see any labeled test points on the mainboard when I looked at mine.
The simplest way would be to backup the existing kernel on your device to your PC and familiarise yourself with booting into diags mode via U-Boot. This means that even if your kernel fails to boot, you can still copy the original kernel back to the Kindle over USB and reflash it using DD. A safer (and probably quicker) way to tackle kernel development and testing is to just load the kernel into memory and boot that instead of flashing it. I covered this process here but haven't tested if it works on a K3 so, YMMV.

The serial port on K3 is documented here - you want an adapter capable of 1.8v; the baud rate is the usual 115200 8N1.
katadelos is offline   Reply With Quote
Old 11-25-2021, 09:42 AM   #22
wishindo
Member
wishindo began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2021
Location: Florida, USA
Device: Kindle Keyboard w/ 3G (k3g), Likebook Mars (T80D)
After no readily available info about the kindles u-boot turned up after a web search, I decided to take a break from working on this niche task.

Quote:
Originally Posted by katadelos View Post
The simplest way would be to backup the existing kernel on your device to your PC and familiarise yourself with booting into diags mode via U-Boot. This means that even if your kernel fails to boot, you can still copy the original kernel back to the Kindle over USB and reflash it using DD.
I gonna try flashing the kernel like this rather than merely booting it as that would require making an extra configuration file. I would - after backing up everything - flash the kernel, replace the modules for the kernel (USB storage can't be built into the kernel, only built as a module. Also symvers would be changed), then boot and test USB storage support. Is this correct?
wishindo is offline   Reply With Quote
Reply

Tags
expansion, hardware modding, modem, storage, usb mass storage


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
K3 Swapping the 3G modem for a 4G modem wishindo Kindle Developer's Corner 5 07-27-2023 10:47 PM
USB (flash drive) to iPad yankgirl Apple Devices 11 07-17-2011 06:48 PM
Does Kindle spread USB virus like USB flash drive? rockchen General Discussions 49 02-17-2011 10:03 AM
FBReader and USB Flash Drive desertblues iRex 0 03-15-2010 09:37 AM


All times are GMT -4. The time now is 11:10 PM.


MobileRead.com is a privately owned, operated and funded community.