Jump to content

Recommended Posts

Posted

Hello

I wrote aind compile little module only for tests:

#include <linux/module.h>
#include <linux/sched.h>

static int errval = 0;

//module_param(errval,int,S_IRWXU);
module_param(errval,int,S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP);
MODULE_PARM_DESC(errval,"Value to return from init function");
int my_init_module(void)
{
	
	
    printk("errval=%d\n",errval);
	return errval;
}

void my_cleanup_module(void)
{
	printk("The module is now unloaded\n");
}
module_init(my_init_module);
module_exit(my_cleanup_module);
MODULE_LICENSE("GPL");

compile by:

make -C /lib/modules/6.6.75-current-sunxi64/build  M=$(PWD) modules

And it cause segmentation fault

onlyme@orangepizero3:~/modules/errors$ sudo insmod errs.ko
[sudo] password for onlyme: 

Message from syslogd@orangepizero3 at Mar 10 13:35:33 ...
 kernel:[  331.593726] Internal error: Oops: 0000000096000004 [#1] SMP

Message from syslogd@orangepizero3 at Mar 10 13:35:33 ...
 kernel:[  331.798432] Code: 540005a0 f9401680 aa1a03e2 aa1703e1 (f9406400) 
Segmentation fault

On Ubuntu x86 and raspbian (raspbery pi 3) it works, on orangepi zero 3 dosnet. Why?

Posted
50 minutes ago, Kopia said:

On Ubuntu x86 and raspbian (raspbery pi 3) it works


Does it work on Armbian X86 and Armbian for Rpi?

Posted (edited)

It works on Ubunru x86, and Raspbian (raspberry pi 3). I didnt check it on Armbian x86 or Armbian Raspberry. But i will check it on Armbian-Raspberry

 

Armbian on raspberry pi 3

Successfull!

uname -r
6.12.17-current-bcm2711

headers:

build -> /usr/src/linux-headers-6.12.17-current-bcm2711

insmod without any messages and lsmod:

sudo lsmod 
Module                  Size  Used by
errs                   12288  0
zram                   36864  2
binfmt_misc            16384  1

Why it doesnt works on Orangepi zero3

Edited by Kopia
Posted
1 hour ago, Kopia said:

Armbian on raspberry pi 3

Successfull!

 

Exactly.

 

1 hour ago, Kopia said:

Why it doesnt works on Orangepi zero3

 

I am not aware of this problem but am sure this is not the only one. Allwinner support quality (and hw itself) is not on the level of mainstream hardware. Many of those devices are - "be happy that you can use them for something", fix problems on your own. We do a lot of fixing, we provide you tools for that, but our resources can't match mountain of problems that can be find in super cheap hardware ... that are leaving factories light speed and their solo mission is to be sold ;) 

Posted

Hi Kopia,

 

I have recently been try to build modules myself and ran into the same issue. Since I am still learning I thought I messed up somewhere but found that even when trying a simple module resulted in the kind of error. I tried the simplest module available by Johannes4linux: https://github.com/Johannes4Linux/Linux_Driver_Tutorial/tree/main/01_hello

I currently have a Pcduino2 (Allwinner A10) running 6.12.9-edge-sunxi, which at first sight appears to load the module correctly but when lsmod is called I then experience a segfault. If I try lsmod before loading the simple hello module then lsmod works as expected.

Before load hello module:

ryan@pcduino2-1:~$ lsmod
Module                  Size  Used by
aes_arm_bs             20480  2
crypto_simd            12288  1 aes_arm_bs
aes_arm                12288  3 aes_arm_bs
ccm                    16384  6
sunrpc                360448  1
rtl8xxxu              167936  0
mac80211              667648  1 rtl8xxxu
cfg80211              618496  2 mac80211,rtl8xxxu
axp20x_adc             16384  0
sun4i_gpadc_iio        12288  0
industrialio           61440  2 sun4i_gpadc_iio,axp20x_adc
rfkill                 20480  3 cfg80211
sun4i_ts               12288  0
libarc4                12288  1 mac80211
sunxi_cedrus           40960  0
v4l2_mem2mem           16384  1 sunxi_cedrus
videobuf2_dma_contig    16384  1 sunxi_cedrus
videobuf2_memops       16384  1 videobuf2_dma_contig
videobuf2_v4l2         16384  2 sunxi_cedrus,v4l2_mem2mem
videobuf2_common       45056  5 sunxi_cedrus,videobuf2_dma_contig,videobuf2_memops,v4l2_mem2mem,videobuf2_v4l2
videodev              188416  3 sunxi_cedrus,v4l2_mem2mem,videobuf2_v4l2
mc                     36864  5 sunxi_cedrus,videobuf2_common,videodev,v4l2_mem2mem,videobuf2_v4l2
cpufreq_dt             16384  0
joydev                 20480  0
input_leds             12288  0
evdev                  16384  4
zram                   24576  2
uio_pdrv_genirq        16384  0
uio                    16384  1 uio_pdrv_genirq
binfmt_misc            20480  1
dm_mod                 98304  0
ip_tables              20480  0
x_tables               24576  1 ip_tables
autofs4                36864  2
pinctrl_axp209         12288  0
lima                   49152  0
gpu_sched              36864  1 lima
sun4i_gpadc            12288  0
drm_shmem_helper       16384  1 lima
sunxi                  12288  0
phy_generic            16384  2 sunxi
display_connector      16384  0
gpio_keys              16384  0
icplus                 12288  1

With hello module loaded:

ryan@pcduino2-1:~/exp-drivers/hello$ sudo dmesg | tail -n 5
[   43.471780] wlx08d8330401aa: RX AssocResp from c0:c9:e3:3b:8b:9e (capab=0x1431 status=0 aid=3)
[   43.490077] usb 1-1: rtl8xxxu_bss_info_changed: HT supported
[   43.740960] wlx08d8330401aa: associated
[ 2938.378205] hello: loading out-of-tree module taints kernel.
[ 2938.380171] hello - Hello, Kernel!

if I try to remove the module, this does not work:

rmmod: ERROR: ../libkmod/libkmod-module.c:856 kmod_module_remove_module() could not remove 'hello': Resource temporarily unavailable
rmmod: ERROR: could not remove module hello: Resource temporarily unavailable

 when calling lsmod:

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.135358] Internal error: Oops: 5 [#1] SMP THUMB2

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.535871] Process lsmod (pid: 1697, stack limit = 0xa7033696)

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.548141] Stack: (0xf0cfde00 to 0xf0cfe000)

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.558824] de00: c1705770 00000000 00000000 ffffffff c3f07000 7cfe460c 67cf1b22 7cfe460c

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.573450] de20: 00000400 c4169a50 00000000 bf9ea044 c4169a68 f0cfdeb0 bf9ea044 c030d02f

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.588095] de40: 00000000 00000000 f0cfde98 c4169a78 00000001 c98f7800 2e8f6000 c3898000

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.602746] de60: c4169fa0 00000000 f0cfdf80 c44e03c0 00000000 00000400 00000001 c0c21784

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.617464] de80: c0355e81 c030d37d 00000400 00000001 01cc6c68 00000400 00000001 00000000

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.632093] dea0: f0cfde90 00000400 00000001 00000000 c44e03c0 00000000 00000000 00000000

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.646728] dec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000400 7cfe460c

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.661312] dee0: 00000400 c44e03c0 c387a800 01cc6c68 f0cfdf80 c02e97b5 00001a55 c392c070

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.675981] df00: c392c070 00000000 00000000 00000000 ffefe31c ef2d9880 00000000 7cfe460c

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.690649] df20: b6ec9fff f0cfdfb0 01cc706c 00000817 c387a800 00000255 c3898000 c0b0abff

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.705276] df40: 00000000 c0b0abff 00000000 00000000 00000000 7cfe460c 00000000 c44e03c0

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.719907] df60: c44e03c0 00000000 00000000 c01002a0 c387a800 00000003 00000000 c02e9fe9

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.734568] df80: 00000000 00000000 c01002a0 7cfe460c bef1f000 01cc52e0 000005e8 b6c15888

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.749269] dfa0: 00000003 c0100061 01cc52e0 000005e8 00000003 01cc6c68 00000400 00000001

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.763901] dfc0: 01cc52e0 000005e8 b6c15888 00000003 0000000a bef1f2b4 00000000 00000000

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.778638] dfe0: 00000003 bef1f1e0 b6bb037b b6b29656 40070030 00000003 00000000 00000000

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.793339] Call trace: 

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.793356]  m_show from seq_read_iter+0xd3/0x37c

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.813529]  seq_read_iter from seq_read+0xa5/0xcc

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.824806]  seq_read from vfs_read+0x79/0x21c

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.835638]  vfs_read from ksys_read+0x45/0x9c

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.846407]  ksys_read from ret_fast_syscall+0x1/0x5c

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.857833] Exception stack(0xf0cfdfa8 to 0xf0cfdff0)

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.869272] dfa0:                   01cc52e0 000005e8 00000003 01cc6c68 00000400 00000001

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.883870] dfc0: 01cc52e0 000005e8 b6c15888 00000003 0000000a bef1f2b4 00000000 00000000

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.898449] dfe0: 00000003 bef1f1e0 b6bb037b b6b29656

Message from syslogd@pcduino2-1 at Mar 10 17:14:04 ...
 kernel:[ 3254.909859] Code: f240 1850 f2cc 08ea (6922) 4641 
Segmentation fault

 

I know this is edge kernel so it is likely to have issues but when I also tried this on my Pcduino3 (Allwinner A20) running 6.6.75-current-sunxi, it then had a segmentation fault straight away.

Posted (edited)

For larger compilations,  like kernel modules/browser/bigger games,   i had faults and complete crashes until i increased zram to a large amount and used a good quality SD card.  It probably won't solve all problems,  but it made a huge difference for me in being able to actually compile larger projects.

 

# configuration values for the armbian-zram-config service
#
# enable the armbian-zram-config service?
ENABLED=true

# Zram swap enabled by default, unless set to disabled
# SWAP=false

# percentage of zram used as swap compared to physically available DRAM.
# Huge overcommitment (300) is possible and sometimes desirable. See
# https://forum.armbian.com/topic/5565-zram-vs-swap/?do=findComment&comment=61082
# and don't forget to adjust $MEM_LIMIT_PERCENTAGE below too.
ZRAM_PERCENTAGE=300

# percentage of DRAM available to zram. If this amount is exceeded the zram
# devices used for swap simply behave as if the device is full. You need to
# adjust/increase this value only if you want to work with massive memory
# overcommitment (ZRAM_PERCENTAGE exceeding 150 for example)
MEM_LIMIT_PERCENTAGE=50

# create how many zram devices max for swap
# ZRAM_MAX_DEVICES=4

 

Edited by dr_toggleswitch

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines