1

I use a specific screen with my raspberry pi 3 that requires a command to set the resolution to him, otherwise it displays nothing. It works fine, the problem is that after each start the file "config.txt" is empty and I have to manually rewrite the command with another pc if I want to use it. It's tedious .. Anyone know how to prevent the automatic deletion of the file content "config.txt"? Thank you Tested with raspbian, ubuntu mate, same problem.

Code i put in config.txt after each start :

max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 1024 600 60 6 0 0 0
6
  • What automatic deletion? I've not heard of any automatic deletion of /boot/config.txt. Doing so makes no sense. Are you using NOOBS?
    – joan
    Oct 7 '16 at 16:56
  • @joan thanks for reply, I'm using ubuntu mate, tried with rasp and same problem. config.txt is not exactly deleted, it is rather empty, when I open it on another pc after using Oct 7 '16 at 19:42
  • There is no reason to delete the contents of /boot/config.txt. Are you sure you are editing the file and saving the edits correctly?
    – joan
    Oct 7 '16 at 19:54
  • @joan Indeed its really strange, but yes, i save file correctly because my screen work, but after reboot the file is empty so my screen no work more.. Oct 7 '16 at 20:22
  • That's why I wondered if you were using a "boot manager" like NOOBS.
    – joan
    Oct 7 '16 at 20:24
1

I had the same problem. After installing Raspbian using NOOBs, the screen was upside down so I used sudo nano /boot/config.txt and added the following:

lcd_rotate=2

After rebooting, the screen was still upside down and when I edited the file, it appeared empty, but the cat command and the Windows text editor showed that it had the original content.

Later I tried sudo vi /boot/config.txt and it showed below:

E325: Attention
Found a swap file by name '/boot/.config.txt.swp' ...
(1) Another program may be editing the same file ...
(2) An edit session for this file crashed ...

Then it displayed the file with ^M (in blue) at the end of last 3 line as follows:

^M

# NOOBS Auto-generated Settings:^M

hdmi_force_hotplug=1^M

Later I deleted the swap file and re-edited the config file (using nano) and rebooted and this time it worked. I wonder if I have a marginal SD card (Samsung 32 GB).

0

I just had same thing, sudo nano boot/config.txt brings up an empty file to edit.

I changed into the boot directory and there were two files

  • config.txt
  • config.txt~

From within the boot directory, config.txt edited fine.

So what I did was

cd /boot   

and then

sudo nano config.txt

At some point I suspect I've made a duplicate file.

1
  • 1
    That's a backup file from vim, mg or emacs. Or perhaps nano.
    – user2497
    Jun 11 '17 at 14:37
0

Most probably the file was edited with an editor (under Windows maybe?) that is configured to use 'MS-Windows/DOS' line endings (CRLF) instead of 'Unix' line endings (LF).

Either configure the editor to use 'Unix' line endings or use the dos2unix or unix2dos utility to convert between the two. To work properly the line endings should be 'Unix' line endings (LF)

2
  • Why does should a CRLF empty a file on boot up? The boot loader may fail to read it properly but it will not empty it.
    – Ingo
    Oct 9 '19 at 22:32
  • You are right, it should not empty the file. In fact my answer fits better to the answer given by @jraustin1 (where the display of ^M is explicitly mentioned)
    – epposan
    Oct 10 '19 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.