Turn off CMA in kernel

What version of kernel did you use? How did you turn off CMA? What errors did you encounter?

For image V171028 you can use boot.ini file to set u-boot environment variables.
You need a SD card with fat32 filesystem, put boot.ini file in it and insert it to VIM, when system bootup will read and parse environment variables in boot.ini file.

boot.ini file format example:

KHADAS-UBOOT-CONFIG

setenv test-boot-ini 1
save

Thanks.

Hi @numbqq

I built the kernel from https://github.com/khadas/linux so assume latest version. I turned off CMA using both menuconfig and by editing the kvim_defconfig file, by commenting out CONFIG_CMA=y and CONFIG_DMA_CMA=y, tried the combinations of these one by one and both together and get the same error.

first error is bypass_4K being an unused variable and generates an error because of strict rules. When i modified the source to the extract below to remove that error then there are a huge number of errors generated after that, bits of structs missing etc.

#ifdef CONFIG_CMA
static int bypass_4K;
#endif

Think the need for CMA is pretty well embedded. Having said that im happy to turn off lots of features as running this headless without a need for GPU so if you know of any way to get past it then im willing to strip lots of the kernel out!

Have tried a boot.ini file on an otherwise blank FAT32 formatted SD card, but couldnt get it to change the boot. My USB to serial device doesnt seem to be working as i just get gibberish out, so getting another one. The boot.ini file was:

KHADAS-UBOOT-CONFIG

setenv cma 0
save

any help appreciated!

You can try to disable CMA in DTS and don’t modify configurations.You can refer to this about disable some reserved memory.

You can use u-boot-tools to set u-boot environment variables in ubuntu.

$ sudo apt-get install u-boot-tools

Download fw_env.config and copy it to /etc/fw_env.config.

$ sudo cp fw_env.config /etc/fw_env.config

Print u-boot environment variables.

$ sudo fw_printenv

Set u-boot environment variables.

$ sudo fw_setenv hello-test 1
$ sudo fw_setenv save
$ sudo fw_printenv hello-test
hello-test=1

Thanks.

well adding cma=100 to the command line appears to have fully stopped it working lol - cant even get it to boot into upgrade mode now! Thru the buttons or Mregister and still cant get serial working (unless anyone can translate this \�-�V�79�;�����3�=��su}W�}wsy���y���_ay���[yM���]YY^���W�-��^+k��%V����UY{��� lol)! Will continue to play

Hi birty,

What’s the purpose of adding cma=100 ?

Thanks.

Hi,

Im trying to make the CMA smaller - though i think i went the wrong way with the numbers, but didnt want to get to 0 straight away given the issue compiling the kernel. But now sadly i have a deveice that wont boot, so im kind of stuck! How do you guys do the initial programme of the devices? Is there somethign i could try?

thanks

I disable CMA in DTS ever. I’m not sure how did you modify the kernel and DTS.

And Mregister mode can’t work?
6390de64cfb905d13810344688da774f4c278211_1_690x344

ive got it back to being recognised on my computer and flashing an image now works ok - but still not booting afterwards. Have ordered a new board as well. Will update if i get it working again or when the new one arrives.

Should have copied your DTS fix the first time instead of messing with u-boot stuff!

What’s the status of your VIM2?

Can flash ROM, but still not boot?

Yes - thats where I am now. Image burns ok, but nothing on reset - no hdmi output, no network connection. Have tried erase all flash - but nothing

Still cant get serial working - is there a recomended serial to usb adaptor, ive tried two and they both output garbage. Have got correct settings and followed the guide in docs on how to set it up

Show photos of how you connect the adapters. Have you tried to swap Rx Tx contacts ? Very often the designation for the adapters is not correct.

@numbqq - Ive got my new VIM2 now - trying to get to a point where i have hugepages on and CMA off.

I have used the Fenix scripts to build now - makes the process easier.

Ive got hugepages on my adding the followign lines to project/fenix/linux/arch/arm64/configs/kvim_defconfig (also added it to defconfig and kvim_defconfig_buildroot for good measure so i didnt have to build mulitple times)
CONFIG_HUGETLBFS=y
CONFIG_HUGETLB_PAGE=y

Using the Fenix scripts then the file (arch/arm64/boot/dts/amlogic/ep-box.dts) you linked to above to change isnt there, but there is a kvim2_linux.dts so i put the changes into that instead. Then i did a make clean and then built again according to fenix scripts instructions - but when i burn the image it doesnt boot (at least doesnt get as far as getting an IP address) as i cant see it on the network.

Any advice apprecitaed

yeah - have tried two and have tried swapping contacts over. Ive used one of them on a microcontroller project before and it worked fine there. Connections are as per http://docs.khadas.com/develop/SetupSerialTool/ using three wires for 0v, tx and rx.

Will find another serial device to connect to make sure its all still working

@birty If you need only console, you can try to remove the whole reserved-memory section, maybe except for secmon and secos:

You will also need to remove every other section that uses reserved memory chunks you deleted, e.g. https://github.com/khadas/linux/blob/Nougat/arch/arm64/boot/dts/kvim2.dts#L213-L218

ok, thanks will give that a go - kind of deleting stuff in the dark to be honest! Wouldnt mind if it didnt take so long to build and for me to find out it didnt work lol

I don’t know your build setup but modifying device tree should be pretty easy: simply run make kvim.dtb in you kernel dir after you modify the tree and you’ll get a dtb almost in an instant.

1 Like

It’s been a while since I’ve worked this low level but CMA should clear out pages (eg inode cache) that others request. On ARM however we use this space for a LOT for things other platforms may have in hardware. I would start by stripping down every driver from the kernel you don’t need (eg audio, video, …) and use serial to get a TTY. Basically get to the level of busybox and then run your application with minimal software.

@guruevi what im seeing (if im reading the output of cat /proc/meminof right!) is that CMA is holding on to its memory allocation and not giving it up - im trying to allocate as many hugepages as i can for my application and cant get much above the 1250 size even with a reboot.

So having done a load more reading and following the tips here - is all i need to do change the dts file and recompile that to remove hardware / drivers from the kernel at boot time rather than recompile the kernel each time? That would save me a lot of time! Sorry if thats a noob question but im a noob when it comes to messing with kernels!

thanks!

You should be able to reclaim that memory by only modifying device tree but I cannot promise you that it won’t crash - if it does, you would need to deselect the drivers in kernel options and recompile the kernel.

By the way, what OS do you need to use? If Linux, perhaps you can try using an OS with mainline kernel which for starters is free of codec_mm CMA reservations? [VIM] Ubuntu Mate with Linux-4.14.11 and U-boot-v2018.01-rc3 ROM alpha-V180106 [SD/USB INSTALLATION]

4 Likes

Ok great - will give that a go!

Yes am using Linux - so will also give that a go!

Thank you!